src/packages/EmbedIO/HttpExceptionHandler.cs
/// <summary>
/// <para>Sends a response with a HTML payload
/// briefly describing the error, including contact information and/or a stack trace
/// if specified via the <see cref="ExceptionHandler.ContactInformation"/>
/// and <see cref="ExceptionHandler.IncludeStackTraces"/> properties, respectively.</para>
/// <para>This handler does not use the <see cref="IHttpException.DataObject">DataObject</see> property.</para>
/// </summary>
/// <param name="context">An <see cref="IHttpContext"/> interface representing the context of the request.</param>
/// <param name="httpException">The HTTP exception.</param>
/// <returns>A <see cref="Task"/> representing the ongoing operation.</returns>
Sends a response with a HTML payload
briefly describing the error, including contact information and/or a stack trace
if specified via the
and  properties, respectively.This handler does not use the DataObject
Sends a response with a HTML payload briefly describing the error including contact information and / or a stack trace if specified via the and properties respectively . This handler does not use the DataObject
public static Task HtmlResponse(IHttpContext context, IHttpException httpException)
            => context.SendStandardHtmlAsync(
                Validate.NotNull(nameof(httpException), httpException).StatusCode,
                text =>
                {
                    text.Write(
                        "<p><strong>Exception type:</strong> {0}<p><strong>Message:</strong> {1}",
                        HttpUtility.HtmlEncode(httpException.GetType().FullName ?? "<unknown>"),
                        HttpUtility.HtmlEncode(httpException.Message));
                    text.Write("<hr><p>If this error is completely unexpected to you, and you think you should not seeing this page, please contact the server administrator");
                    if (!string.IsNullOrEmpty(ExceptionHandler.ContactInformation))
                        text.Write(" ({0})", HttpUtility.HtmlEncode(ExceptionHandler.ContactInformation));
                    text.Write(", informing them of the time this error occurred and the action(s) you performed that resulted in this error.</p>");
                    if (ExceptionHandler.IncludeStackTraces)
                    {
                        text.Write(
                            "</p><p><strong>Stack trace:</strong></p><br><pre>{0}</pre>",
                            HttpUtility.HtmlEncode(httpException.StackTrace));
                    }
                });
public static Task HtmlResponse ( IHttpContext context , IHttpException httpException ) => context . SendStandardHtmlAsync ( Validate . NotNull ( nameof ( httpException ) , httpException ) . StatusCode , text => { text . Write ( " " , HttpUtility . HtmlEncode ( httpException . GetType ( ) . FullName ?? " " ) , HttpUtility . HtmlEncode ( httpException . Message ) ) ; text . Write ( " " ) ; if ( ! string . IsNullOrEmpty ( ExceptionHandler . ContactInformation ) ) text . Write ( " " , HttpUtility . HtmlEncode ( ExceptionHandler . ContactInformation ) ) ; text . Write ( " " ) ; if ( ExceptionHandler . IncludeStackTraces ) { text . Write ( " " , HttpUtility . HtmlEncode ( httpException . StackTrace ) ) ; } } ) ;
Sends a response with a HTML payload
briefly describing the error, including contact information and/or a stack trace
if specified via the
and  properties, respectively.This handler does not use the DataObject
Sends a response with a HTML payload briefly describing the error including contact information and / or a stack trace if specified via the and properties respectively . This handler does not use the DataObject
A  representing the ongoing operation.
A representing the ongoing operation .
context
IHttpContext
An  interface representing the context of the request.
An interface representing the context of the request .
httpException
IHttpException
The HTTP exception.
The HTTP exception .