Class StrataraProblemDetailsExceptionHandler
- Namespace
- Stratara.ServiceDefaults.AspNetCore
- Assembly
- Stratara.ServiceDefaults.AspNetCore.dll
Maps the framework's own failure types to an RFC 7807 problem response, so a caller receives one shape for every framework rejection instead of one shape per failure type.
public sealed class StrataraProblemDetailsExceptionHandler : IExceptionHandler
- Inheritance
-
StrataraProblemDetailsExceptionHandler
- Implements
- Inherited Members
- Extension Methods
Remarks
Handles exactly three types: a validation rejection becomes 400 carrying the failures
grouped by the field each concerns; an authorization refusal and a tenant-access denial each
become 403. Everything else is left alone and propagates unchanged — a host with its own
error model keeps it, and a bug in a handler still reaches the host's own diagnostics rather than
being flattened into a tidy 500.
Registered by AddStrataraProblemDetails(); a host that does not call it converts nothing.
Methods
TryHandleAsync(HttpContext, Exception, CancellationToken)
Tries to handle the specified exception asynchronously within the ASP.NET Core pipeline. Implementations of this method can provide custom exception-handling logic for different scenarios.
public ValueTask<bool> TryHandleAsync(HttpContext httpContext, Exception exception, CancellationToken cancellationToken)
Parameters
httpContextHttpContextThe HttpContext for the request.
exceptionExceptionThe unhandled exception.
cancellationTokenCancellationTokenThe cancellation token.