Class StrataraProblemDetailsServiceCollectionExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Stratara.ServiceDefaults.AspNetCore.dll
Registers the mapping from Stratara's own failure types to RFC 7807 problem responses.
public static class StrataraProblemDetailsServiceCollectionExtensions
- Inheritance
-
StrataraProblemDetailsServiceCollectionExtensions
- Inherited Members
Methods
AddStrataraProblemDetails(IServiceCollection)
Registers StrataraProblemDetailsExceptionHandler and the ASP.NET problem-details
service, so a validation rejection becomes 400 with the failures grouped by field, and
an authorization refusal or tenant-access denial becomes 403 — all in one shape.
public static IServiceCollection AddStrataraProblemDetails(this IServiceCollection services)
Parameters
servicesIServiceCollectionThe service collection.
Returns
- IServiceCollection
The same service collection for chaining.
Examples
One RFC 7807 shape for a validation rejection (400 with the failures grouped by field) and for an authorization or tenant-access refusal (403). Pair it with the exception handler:
services.AddStrataraProblemDetails();
app.UseExceptionHandler();
Remarks
The mapping is opt-in and converts nothing a host does not ask it to: any failure the framework did not raise propagates unchanged, so a host keeping its own error model simply does not call this.
Call app.UseExceptionHandler() in the pipeline for the handler to run. Without it the
handler is registered but never reached, and failures propagate as if the mapping were absent.