Table of Contents

Class TrellisJsonValidationException

Namespace
Trellis
Assembly
Trellis.Core.dll

Thrown by Trellis JSON converters when a structured value object's invariants are violated during deserialization (e.g., Money's amount/currency rules).

[SuppressMessage("Roslynator", "RCS1194:Implement exception constructors", Justification = "JsonException's protected serialization ctor and 4/5-arg ctors are intentionally not re-exposed; the three standard ctors cover all supported usage.")]
public sealed class TrellisJsonValidationException : JsonException, ISerializable
Inheritance
TrellisJsonValidationException
Implements
Inherited Members
Extension Methods

Remarks

This is a marker subclass of JsonException. Trellis.Asp's ScalarValueValidationMiddleware recognizes it and surfaces the message (and Path, when present) in the resulting Problem Details payload — restoring DX parity with MVC's model-binder error reporting, which already includes per-field JsonException messages.

Plain JsonExceptions (e.g., those thrown by System.Text.Json when a JSON value can't be coerced to a CLR type) are deliberately not surfaced because their messages can include internal type names. Trellis converters opt in to message surfacing by throwing this subclass with a curated message — for example error.GetDisplayMessage() from a Result failure.

Constructors

TrellisJsonValidationException()

Default constructor (RCS1194).

public TrellisJsonValidationException()

TrellisJsonValidationException(string)

Creates an instance with the supplied curated, user-safe message.

public TrellisJsonValidationException(string message)

Parameters

message string

TrellisJsonValidationException(string, Exception)

Wraps an inner exception with the supplied message.

public TrellisJsonValidationException(string message, Exception innerException)

Parameters

message string
innerException Exception