KestrunResponse.WriteErrorResponseAsync method (1 of 2)

Asynchronously writes an error response based on an exception. Chooses JSON/YAML/XML/plain-text based on override → Accept → default JSON.

public Task WriteErrorResponseAsync(Exception ex, int statusCode = 500, string? contentType = null, 
    bool includeStack = true)
parameter description
ex The exception to report.
statusCode The HTTP status code for the response.
contentType The MIME type of the response content.
includeStack Whether to include the stack trace in the response.

See Also


KestrunResponse.WriteErrorResponseAsync method (2 of 2)

Write an error response with a custom message. Chooses JSON/YAML/XML/plain-text based on override → Accept → default JSON.

public Task WriteErrorResponseAsync(string message, int statusCode = 500, 
    string? contentType = null, string? details = null)

See Also