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.

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

Updated