Delegate TypedExceptionNormalizer<TException>
Converts an unexpected exception of a registered type into an enriched HttpRequestException.
Namespace: NanoRoute
Assembly: NanoRoute.dll
Syntax
public delegate HttpRequestException TypedExceptionNormalizer<TException>(TException exception) where TException : Exception
Parameters
| Type | Name | Description |
|---|---|---|
| TException | 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. |
Type Parameters
| Name | Description |
|---|---|
| TException | The exception type handled by the normalizer. |
Remarks
Use this delegate with Map<TException>(TypedExceptionNormalizer<TException>) to register typed normalizers without manually casting from Exception. Exception handlers check the exact runtime type first, then walk base exception types, so a base-type normalizer handles derived exceptions unless a more specific normalizer is registered.
Examples
options.Map<InvalidOperationException>
(
static ex => new HttpRequestException("Bad state", ex, HttpStatusCode.Conflict)
);