# Exception Handling Middleware

*noun*

say it: **“ek-SEP-shun HAND-ling MID-ul-wair”** **/ɪkˈsɛpʃən ˈhændlɪŋ ˈmɪdəlwɛr/**

Middleware that catches unhandled exceptions anywhere in the app and returns a clean error response.

## What is **Exception Handling Middleware**?

`UseExceptionHandler` catches unhandled exceptions anywhere in the pipeline and turns them into a clean 500 response instead of a crash or a stack trace.

```csharp
builder.Services.AddProblemDetails();
var app = builder.Build();
app.UseExceptionHandler();
```

## In a sentence

- “Our **exception handling middleware** turns any crash into a tidy 500 response.”

Level: Journeyman · [More ASP.NET Core terms at this level](https://www.ask-codey.com/glossary?category=aspnet-core&level=3)

Updated: November 9, 2026

Source: https://www.ask-codey.com/glossary/exception-handling-middleware
