Class ExceptionHandlerExtensions
extensions for global exception handling
Inherited Members
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public static class ExceptionHandlerExtensions
Methods
UseDefaultExceptionHandler(IApplicationBuilder, ILogger?, bool, bool)
registers the default global exception handler which will log the exceptions on the server and return a user-friendly json response to the client when unhandled exceptions occur. TIP: when using this exception handler, you may want to turn off the asp.net core exception middleware logging to avoid duplication like so:
"Logging": { "LogLevel": { "Default": "Warning", "Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware": "None" } }
Declaration
public static IApplicationBuilder UseDefaultExceptionHandler(this IApplicationBuilder app, ILogger? logger = null, bool logStructuredException = false, bool useGenericReason = false)
Parameters
| Type | Name | Description |
|---|---|---|
| IApplicationBuilder | app | |
| ILogger | logger | an optional logger instance |
| bool | logStructuredException | set to true if you'd like to log the error in a structured manner |
| bool | useGenericReason | set to true if you don't want to expose the actual exception reason in the json response sent to the client |
Returns
| Type | Description |
|---|---|
| IApplicationBuilder |