public async Task <IExceptionHandlingResult> HandleAsync(HttpContext httpContext) { var exceptionHandlerPathFeature = httpContext.Features.Get <IExceptionHandlerFeature>(); if (exceptionHandlerPathFeature == null) { return(new ExceptionHandlerFeatureNotSupportedResult()); } var exception = exceptionHandlerPathFeature.Error; if (exception == null) { return(new NoExceptionResult()); } var context = new ExceptionHandlingContext(httpContext, exception, new ExceptionNotHandledResult(exception)); foreach (var handler in _handlers) { if (await handler.KnowHowToHandleAsync(exception)) { await handler.ExecuteAsync(context); } } return(context.Result); }
protected override Task ExecuteCoreAsync(ExceptionHandlingContext <TException> context) { HandleCoreWasCalled = true; HttpContext = context.HttpContext; Exception = context.Error; return(base.ExecuteCoreAsync(context)); }
protected virtual Task ExecuteCoreAsync(ExceptionHandlingContext <TException> context) { return(Task.CompletedTask); }
public virtual Task ExecuteAsync(ExceptionHandlingContext context) { context.HttpContext.Response.StatusCode = StatusCode; context.Result = new ExceptionHandledResult(context.Error); return(ExecuteCoreAsync(new ExceptionHandlingContext <TException>(context))); }
public ExceptionHandlingContext(ExceptionHandlingContext <TException> previous) : this(previous.HttpContext, previous.Error, previous.Result) { }
public Task ExecuteAsync(ExceptionHandlingContext context) { throw new NotImplementedException(); }