예제 #1
0
        async Task IFilter <ConsumeContext <T> > .Send(ConsumeContext <T> context, IPipe <ConsumeContext <T> > next)
        {
            try
            {
                await next.Send(context);
            }
            catch (AggregateException ex)
            {
                if (!ex.InnerExceptions.Any(x => _exceptionFilter.Match(x)))
                {
                    throw;
                }

                if (_log.IsErrorEnabled)
                {
                    _log.Error($"Rescue<{TypeMetadataCache<T>.ShortName}>", ex);
                }

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

                if (_log.IsErrorEnabled)
                {
                    _log.Error($"Rescue<{TypeMetadataCache<T>.ShortName}>", ex);
                }

                await _rescuePipe.Send(context);
            }
        }
        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);
            }
        }
예제 #3
0
 public bool CanRetry(Exception exception)
 {
     return(_filter.Match(exception));
 }