Table of Contents

Class TrellisValidationFormatException

Namespace
Trellis
Assembly
Trellis.Core.dll

A FormatException that also carries the structured validation failure that caused it.

public sealed class TrellisValidationFormatException : FormatException, ISerializable
Inheritance
TrellisValidationFormatException
Implements
Inherited Members
Extension Methods

Remarks

A parse failure has to satisfy two contracts at once, and no single exception type satisfies both. IParsable<TSelf> requires malformed input to be signalled with a FormatException; the ASP boundary recognizes a structured validation failure only through TrellisJsonValidationException, which is a JsonException. So the failure crosses the boundary in two hops: Parse throws this type, and the JSON converter that called Parse rethrows it as a TrellisJsonValidationException carrying the same InvalidInput.

Deriving from FormatException rather than introducing a sibling type is what keeps existing catch (FormatException) sites matching, and the base message is the unchanged flattened parse message, so a caller that catches and logs sees exactly what it saw before. The structure is strictly additional.

It lives in Trellis.Core, and is public, because it is thrown from Trellis.Primitives and caught in Trellis.Core. Making it internal would put it out of reach of the throwing sites, and moving it to Trellis.Primitives would force Core's converter to reference Primitives, inverting the dependency.

Constructors

TrellisValidationFormatException()

Initializes a new instance of the TrellisValidationFormatException class.

public TrellisValidationFormatException()

TrellisValidationFormatException(string?)

Initializes a new instance of the TrellisValidationFormatException class with a message.

public TrellisValidationFormatException(string? message)

Parameters

message string

The flattened parse message, unchanged from what callers saw before.

TrellisValidationFormatException(string?, Exception?)

Initializes a new instance of the TrellisValidationFormatException class with a message and an inner exception.

public TrellisValidationFormatException(string? message, Exception? innerException)

Parameters

message string

The flattened parse message.

innerException Exception

The exception that caused this one.

TrellisValidationFormatException(string?, InvalidInput?)

Initializes a new instance of the TrellisValidationFormatException class carrying the structured failure.

public TrellisValidationFormatException(string? message, Error.InvalidInput? invalidInput)

Parameters

message string

The flattened parse message, unchanged from what callers saw before.

invalidInput Error.InvalidInput

The structured failure the parse produced.

Properties

InvalidInput

Gets the structured validation failure, when the parse produced one.

public Error.InvalidInput? InvalidInput { get; init; }

Property Value

Error.InvalidInput