private async Task InvokeNextExceptionFilterAsync() { try { var next = State.ExceptionNext; var state = (object)null; var scope = Scope.Exception; var isCompleted = false; while (!isCompleted) { await Next(ref next, ref scope, ref state, ref isCompleted); } } catch (Exception exception) { _exceptionContext = new ExceptionContextEx(_controllerContext, exception) { ExceptionDispatchInfo = ExceptionDispatchInfo.Capture(exception), }; } }
private static void Rethrow(ExceptionContextEx context) { if (context == null) { return; } if (context.ExceptionHandled) { return; } if (context.ExceptionDispatchInfo != null) { context.ExceptionDispatchInfo.Throw(); } if (context.Exception != null) { throw context.Exception; } }