Interface IApiExceptionHandler
Maps exceptions thrown while processing API requests to the errors reported to clients. Used by ApiExceptionMiddleware for regular responses and by streaming responses for exceptions thrown after the stream has started, so a single implementation provides consistent error handling (e.g. logging unexpected exceptions and reporting a reference ID) for both.
Namespace: Singulink.Net.Http.Api.Service
Assembly: Singulink.Net.Http.Api.Service.dll
Syntax
public interface IApiExceptionHandler
Remarks
ApiExceptionHandler provides the recommended default behavior and can be registered directly via AddApiExceptionHandler(IServiceCollection) or derived from to add application-specific mappings. If no handler is registered, ApiException instances are reported as-is and other exceptions propagate through the request pipeline (or, for streaming responses that have already started, are reported as a generic server error, with details included only in development environments).
Methods
| Name | Description |
|---|---|
| HandleAsync(HttpContext, Exception) | Maps the specified exception to the ApiException that should be reported to the client. |