API

UseExceptionHandler

Registers downstream exception handling for eligible failures before response commitment.

Formal Syntax & Structure

csharp syntaxcsharp
app.UseExceptionHandler(error => error.Run(ctx => Results.Problem(statusCode: 500).ExecuteAsync(ctx)));

Working Example

Example Snippetcsharp
// Documentary fragment; see linked lesson for context.app.UseExceptionHandler(error => error.Run(ctx => Results.Problem(statusCode: 500).ExecuteAsync(ctx)));
C# & .NET Reference