exception handler middleware
ASP.NET Core middleware, added with app.UseExceptionHandler(), that catches unhandled exceptions from later components and returns a safe error response.
In more detail
Put it first so it surrounds everything. Combined with AddProblemDetails it returns a Problem Details body and logs the exception without exposing internals.
Related terms
- middleware pipeline — The ordered chain of middleware every HTTP request passes through on the way in, and in reverse on the way out.
- Problem Details — A standard JSON shape for HTTP error responses, defined in RFC 9457, with members such as type, title, status, detail and instance.
- exception — An error object a program raises to stop normal flow and report that something went wrong.
Taught in
- The ASP.NET Core Middleware Pipeline — Modern .NET Core, C# & Enterprise Microservices
- Global Exception Handling and Problem Details — Modern .NET Core, C# & Enterprise Microservices