private async Task HandleExceptionAsync(MethodExceptionContext exceptionContext) { var attributes = GetInvocationMethodFilterAttributes(exceptionContext.Invocation, exceptionContext.InvocationContext); var exceptionFilterAttributes = attributes.OfType <ExceptionFilterAttribute>().ToList(); if (exceptionFilterAttributes.Count == 0) { throw exceptionContext.Exception; } foreach (var f in exceptionFilterAttributes) { try { if (!exceptionContext.Handled) { await f.OnExceptionAsync(exceptionContext).ConfigureAwait(false); } } catch (Exception ex) { throw new AggregateException(ex.Message, ex, exceptionContext.Exception); } } if (!exceptionContext.Handled) { throw exceptionContext.Exception; } }
public virtual Task OnExceptionAsync(MethodExceptionContext exceptionContext) { try { OnException(exceptionContext); } catch (Exception ex) { TaskHelpers.FromError(ex); } return TaskHelpers.DefaultCompleted; }
public virtual Task OnExceptionAsync(MethodExceptionContext exceptionContext) { try { OnException(exceptionContext); } catch (Exception ex) { return(TaskHelpers.FromError(ex)); } return(TaskHelpers.DefaultCompleted); }
public virtual void OnException(MethodExceptionContext exceptionContext) { }