Ejemplo n.º 1
0
 public async Task Send(ExecuteActivityContext <TActivity, TArgument> context, IPipe <ExecuteActivityContext <TActivity, TArgument> > next)
 {
     try
     {
         await next.Send(context).ConfigureAwait(false);
     }
     catch (Exception ex)
     {
         if (!context.TryGetPayload(out IErrorTransport transport))
         {
             throw new TransportException(context.ReceiveContext.InputAddress, $"The {nameof(IErrorTransport)} was not available on the {nameof(ReceiveContext)}.");
         }
         var exceptionReceiveContext = new RescueExceptionReceiveContext(context.ReceiveContext, ex);
         await transport.Send(exceptionReceiveContext);
     }
 }
        async Task IFilter <ReceiveContext> .Send(ReceiveContext context, IPipe <ReceiveContext> next)
        {
            try
            {
                await next.Send(context).ConfigureAwait(false);
            }
            catch (AggregateException ex)
            {
                if (!ex.InnerExceptions.Any(x => _exceptionFilter.Match(x)))
                {
                    throw;
                }

                if (_log.IsErrorEnabled)
                {
                    _log.Error("Rescuing exception", ex);
                }

                var exceptionContext = new RescueExceptionReceiveContext(context, ex);

                await _rescuePipe.Send(exceptionContext).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                if (!_exceptionFilter.Match(ex))
                {
                    throw;
                }

                if (_log.IsErrorEnabled)
                {
                    _log.Error("Rescuing exception", ex);
                }

                var exceptionContext = new RescueExceptionReceiveContext(context, ex);

                await _rescuePipe.Send(exceptionContext).ConfigureAwait(false);
            }
        }