Delegate ExceptionNormalizer
Converts an unexpected exception into an enriched HttpRequestException.
Namespace: NanoRoute
Assembly: NanoRoute.dll
Syntax
public delegate HttpRequestException ExceptionNormalizer(Exception exception)
Parameters
| Type | Name | Description |
|---|---|---|
| Exception | exception | The exception thrown by a later handler in the routing pipeline. |
Returns
| Type | Description |
|---|---|
| HttpRequestException | The HttpRequestException that should be thrown by the exception-handling middleware. |
Remarks
Normalizers are configured with Map<TException>(TypedExceptionNormalizer<TException>). Existing HttpRequestException and OperationCanceledException values are not normalized by AddExceptionHandler<TBuilder>(TBuilder). Exceptions thrown by a normalizer propagate from the exception-handling middleware.
Examples
builder.AddExceptionHandler(options => options.Map<InvalidOperationException>
(
static ex => new HttpRequestException("Bad state", ex, HttpStatusCode.Conflict)
));