Class ExceptionHandler
Provides standard handlers for unhandled exceptions at both module and server level.
Inherited Members
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 |
EmptyResponseWithHeaders(IHttpContext, Exception)
Sends an empty 500 Internal Server Error
response,
with the following additional headers:
Header | Value |
---|---|
X-Exception-Type | The name (without namespace) of the type of exception that was thrown. |
X-Exception-Message | The |
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 |
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 |