Handling Global Exceptions in ASP.NET Core

AddProblemDetails and UseExceptionHandler catch every exception an action doesn't, log it, and answer with a tidy 500 problem details response that never shows the stack trace. An IExceptionHandler can answer chosen exceptions with a better status, such as 409 Conflict.

Updated

Cheat sheet: Handling Global Exceptions in ASP.NET Core
Category
ASP.NET Core
Level
Freelancer
Tags
aspnet-core, Exception Handling Middleware, IExceptionHandler, Problem Details in ASP.NET Core, rest-api