Back to Practical Aspnetcore

Implement multiple IExceptionHandler to handle unhandled exceptions

projects/exception-handler-middleware/iexception-handler-2/README.md

latest406 B
Original Source

Implement multiple IExceptionHandler to handle unhandled exceptions

Implement multiple IExceptionHandler for handling exceptions.

csharp
builder.Services.AddExceptionHandler<TimeOutHandler>();
builder.Services.AddExceptionHandler<DefaultExceptionHandler>();

In this case the order of the handles are important. TimeOutHandler is called first then DefaultExceptionHandler.