Unosquare
    Show / Hide Table of Contents

    Class ExceptionHandler

    Provides standard handlers for unhandled exceptions at both module and server level.

    Inheritance
    Object
    ExceptionHandler
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: EmbedIO
    Syntax
    public static class ExceptionHandler

    Fields

    Default

    The default handler used by WebServerBase<TOptions>.

    This is the same as HtmlResponse(IHttpContext, Exception).

    Declaration
    public static readonly ExceptionHandlerCallback Default
    Field Value
    Type Description
    ExceptionHandlerCallback

    ExceptionMessageHeaderName

    The name of the response header used by the EmptyResponseWithHeaders(IHttpContext, Exception) handler to transmit the message of the exception to the client.

    Declaration
    public const string ExceptionMessageHeaderName = "X-Exception-Message"
    Field Value
    Type Description
    String

    ExceptionTypeHeaderName

    The name of the response header used by the EmptyResponseWithHeaders(IHttpContext, Exception) handler to transmit the type of the exception to the client.

    Declaration
    public const string ExceptionTypeHeaderName = "X-Exception-Type"
    Field Value
    Type Description
    String

    Properties

    ContactInformation

    Gets or sets the contact information to include in exception responses.

    Declaration
    public static string ContactInformation { get; set; }
    Property Value
    Type Description
    String

    IncludeStackTraces

    Gets or sets a value indicating whether to include stack traces in exception responses.

    Declaration
    public static bool IncludeStackTraces { get; set; }
    Property Value
    Type Description
    Boolean

    Methods

    EmptyResponse(IHttpContext, Exception)

    Sends an empty 500 Internal Server Error response.

    Declaration
    public static Task EmptyResponse(IHttpContext context, Exception exception)
    Parameters
    Type Name Description
    IHttpContext context

    An IHttpContext interface representing the context of the request.

    Exception exception

    The unhandled exception. This parameter is ignored, because there is no possible use for it in an empty response.

    Returns
    Type Description
    Task

    A representing the ongoing operation.

    EmptyResponseWithHeaders(IHttpContext, Exception)

    Sends an empty 500 Internal Server Error response, with the following additional headers:

    HeaderValue
    X-Exception-TypeThe name (without namespace) of the type of exception that was thrown.
    X-Exception-MessageThe Message property of the exception.

    The aforementioned header names are available as the ExceptionTypeHeaderName and ExceptionMessageHeaderName properties, respectively.

    Declaration
    public static Task EmptyResponseWithHeaders(IHttpContext context, Exception exception)
    Parameters
    Type Name Description
    IHttpContext context

    An IHttpContext interface representing the context of the request.

    Exception exception

    The unhandled exception.

    Returns
    Type Description
    Task

    A representing the ongoing operation.

    HtmlResponse(IHttpContext, Exception)

    Sends a 500 Internal Server Error response with a HTML payload briefly describing the error, including contact information and/or a stack trace if specified via the ContactInformation and IncludeStackTraces properties, respectively.

    Declaration
    public static Task HtmlResponse(IHttpContext context, Exception exception)
    Parameters
    Type Name Description
    IHttpContext context

    An IHttpContext interface representing the context of the request.

    Exception exception

    The unhandled exception.

    Returns
    Type Description
    Task

    A representing the ongoing operation.

    See Also

    OnUnhandledException
    OnUnhandledException

    Comments

    Back to top Copyright © 2017-2019 Unosquare