Skip to content

Instantly share code, notes, and snippets.

@AnthonyGiretti
Created June 14, 2023 03:18
Show Gist options
  • Save AnthonyGiretti/ca7b8404ecbbb0255b723a4fa194ef1d to your computer and use it in GitHub Desktop.
Save AnthonyGiretti/ca7b8404ecbbb0255b723a4fa194ef1d to your computer and use it in GitHub Desktop.
Register in order two chained Exception handlers
using DemoAspNetCore8.ErrorHandling;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddExceptionHandler<TimeOutExceptionHandler>();
builder.Services.AddExceptionHandler<DefaultExceptionHandler>();
var app = builder.Build();
app.UseExceptionHandler(opt => { });
app.MapGet("/Exception", () => {
throw new NotImplementedException();
});
app.MapGet("/Timeout", () => {
throw new TimeoutException();
});
app.Run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment