Skip to main content
Table of Contents

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

httpContext HttpContext

The HttpContext for the request.

exception Exception

The unhandled exception.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask<bool>

A task that represents the asynchronous read operation. The value of its Result property contains the result of the handling operation. true if the exception was handled successfully; otherwise false.