Class ValueObjectJsonException
Namespace: AdCodicem.ValueObjects
Assembly: AdCodicem.ValueObjects.Abstractions.dll
A value object refused the value System.Text.Json was reading or writing.
[Serializable]
public sealed class ValueObjectJsonException : JsonException, ISerializable
Inheritance
object ← Exception ← JsonException ← ValueObjectJsonException
Implements
Inherited Members
JsonException.BytePositionInLine, JsonException.LineNumber, JsonException.Message, JsonException.Path, Exception.GetBaseException(), Exception.GetType(), Exception.ToString(), Exception.Data, Exception.HelpLink, Exception.HResult, Exception.InnerException, Exception.Message, Exception.Source, Exception.StackTrace, Exception.TargetSite, object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
The converter the generator emits throws it, and so do the converter for a value object written by hand and the
converter of AnyEntityId, wherever they refuse a value: a value or a dictionary key a rule rejects, a token
of the wrong kind or that the underlying type cannot hold, and a value to write that its type rejects. It is a
catch (JsonException) still catches it, and System.Text.Json treats it as
any exception a converter throws: it sets
It carries the code of the rule, which it also stores in
Constructors
ValueObjectJsonException(string?, Type, string)
Initializes a new instance of the
public ValueObjectJsonException(string? message, Type valueObjectType, string errorCode)
Parameters
message string?
Message naming the value object and the rule, or null for System.Text.Json to write its own, "The JSON value could not be converted to …", followed by the path, as it does for a token it cannot read.
valueObjectType Type
Value object type that refused the value.
errorCode string
Stable, machine-readable code of the violated rule.
Exceptions
valueObjectType is null.
errorCode is null or empty.
Properties
ErrorCode
Gets the stable, machine-readable code of the violated rule.
public string ErrorCode { get; }
Property Value
Remarks
The code of the rule that fired, or null, which only a
value object that cannot be null is handed.
ValueObjectType
Gets the value object type that refused the value.
public Type ValueObjectType { get; }