Unosquare
    Show / Hide Table of Contents

    Class HttpExceptionHandler

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

    Inheritance
    Object
    HttpExceptionHandler
    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 HttpExceptionHandler
    Remarks

    Where applicable, HTTP exception handlers defined in this class use the ContactInformation and IncludeStackTraces properties to customize their behavior.

    Fields

    Default

    The default handler used by WebServerBase<TOptions>.

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

    Declaration
    public static readonly HttpExceptionHandlerCallback Default
    Field Value
    Type Description
    HttpExceptionHandlerCallback

    Methods

    DataResponse(ResponseSerializerCallback)

    Gets a HttpExceptionHandlerCallback that will serialize a HTTP exception's DataObject property and send it as a JSON response.

    Declaration
    public static HttpExceptionHandlerCallback DataResponse(ResponseSerializerCallback serializerCallback)
    Parameters
    Type Name Description
    ResponseSerializerCallback serializerCallback

    A ResponseSerializerCallback used to serialize data and send it to the client.

    Returns
    Type Description
    HttpExceptionHandlerCallback

    A HttpExceptionHandlerCallback.

    EmptyResponse(IHttpContext, IHttpException)

    Sends an empty response.

    Declaration
    public static Task EmptyResponse(IHttpContext context, IHttpException httpException)
    Parameters
    Type Name Description
    IHttpContext context

    An IHttpContext interface representing the context of the request.

    IHttpException httpException

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

    Returns
    Type Description
    Task

    A representing the ongoing operation.

    FullDataResponse(ResponseSerializerCallback)

    Gets a HttpExceptionHandlerCallback that will serialize a HTTP exception's Message and DataObject properties and send them as a JSON response.

    The response will be a JSON object with a message property and a data property.

    Declaration
    public static HttpExceptionHandlerCallback FullDataResponse(ResponseSerializerCallback serializerCallback)
    Parameters
    Type Name Description
    ResponseSerializerCallback serializerCallback

    A ResponseSerializerCallback used to serialize data and send it to the client.

    Returns
    Type Description
    HttpExceptionHandlerCallback

    A HttpExceptionHandlerCallback.

    HtmlResponse(IHttpContext, IHttpException)

    Sends a 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.

    This handler does not use the DataObject property.

    Declaration
    public static Task HtmlResponse(IHttpContext context, IHttpException httpException)
    Parameters
    Type Name Description
    IHttpContext context

    An IHttpContext interface representing the context of the request.

    IHttpException httpException

    The HTTP exception.

    Returns
    Type Description
    Task

    A representing the ongoing operation.

    PlainTextResponse(IHttpContext, IHttpException)

    Sends a HTTP exception's Message property as a plain text response.

    This handler does not use the DataObject property.

    Declaration
    public static Task PlainTextResponse(IHttpContext context, IHttpException httpException)
    Parameters
    Type Name Description
    IHttpContext context

    An IHttpContext interface representing the context of the request.

    IHttpException httpException

    The HTTP exception.

    Returns
    Type Description
    Task

    A representing the ongoing operation.

    See Also

    OnHttpException
    OnHttpException

    Comments

    Back to top Copyright © 2017-2019 Unosquare