Ejemplo n.º 1
0
    public async Task OnCommand(
        ICommand command, CommandContext context,
        CancellationToken cancellationToken)
    {
        if (command is IMetaCommand)
        {
            goto Skip;
        }

        var finalHandler = context.ExecutionState.FindFinalHandler();

        if (finalHandler?.GetHandlerService(command, context) is not IReplicaService)
        {
            goto Skip;
        }

        try {
            await context.InvokeRemainingHandlers(cancellationToken).ConfigureAwait(false);
        }
        catch (HttpRequestException e) {
            var isFailedToFetch = StringComparer.Ordinal.Equals(e.Message, "TypeError: Failed to fetch");
            if (isFailedToFetch)
            {
                throw Errors.BackendIsUnreachable(e);
            }
            throw;
        }
        return;

Skip:
        await context.InvokeRemainingHandlers(cancellationToken).ConfigureAwait(false);
    }