Search Results for

    Show / Hide Table of Contents

    Class ExceptionHandlerExtensions

    extensions for global exception handling

    Inheritance
    object
    ExceptionHandlerExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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
    In this article
    Back to top Developed by Đĵ ΝιΓΞΗΛψΚ and contributors / Licensed under MIT / Website generated by DocFX