Class JsonErrorDetailsConfig
Configures how AddJsonErrorDetails<TBuilder>(TBuilder) creates JSON ErrorDetails responses.
Implements
Inherited Members
Namespace: NanoRoute
Assembly: NanoRoute.dll
Syntax
public sealed record JsonErrorDetailsConfig : IEquatable<JsonErrorDetailsConfig>
Remarks
Instances are stored in Metadata by ConfigureJsonErrorDetails<TBuilder>(TBuilder, ConfigureBuilderDelegate<JsonErrorDetailsConfig>). The configuration visible from the builder scope is captured when JSON error-detail middleware is registered.
Examples
builder.ConfigureJsonErrorDetails(config => config with
{
PopulateErrorInfo = true,
ErrorDetailsTypeInfo = MyJsonContext.Default.ErrorDetails
});
Constructors
JsonErrorDetailsConfig()
Declaration
public JsonErrorDetailsConfig()
Properties
Default
Gets the default JSON error-detail configuration.
Declaration
public static JsonErrorDetailsConfig Default { get; }
Property Value
| Type | Description |
|---|---|
| JsonErrorDetailsConfig |
Examples
JsonErrorDetailsConfig config = JsonErrorDetailsConfig.Default;
ErrorDetailsTypeInfo
Gets the JSON serialization metadata used for ErrorDetails responses.
Declaration
public JsonTypeInfo<ErrorDetails> ErrorDetailsTypeInfo { get; init; }
Property Value
| Type | Description |
|---|---|
| JsonTypeInfo<ErrorDetails> |
Remarks
Replace this value to use custom source-generated metadata, property naming, converters, or other serializer behavior for the error payload.
Examples
builder.ConfigureJsonErrorDetails(config => config with
{
ErrorDetailsTypeInfo = MyJsonContext.Default.ErrorDetails
});
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when the assigned value is null. |
PopulateErrorInfo
Gets a value indicating whether developer-facing diagnostic details should be included in JSON error responses.
Declaration
public bool PopulateErrorInfo { get; init; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Diagnostic details may contain exception messages or stack traces. Keep this value false for production responses unless the caller is trusted to see those details.
Examples
builder.ConfigureJsonErrorDetails(config => config with
{
PopulateErrorInfo = true
});