Class DomainError
- Namespace
- JD.Domain.Abstractions
- Assembly
- JD.Domain.Abstractions.dll
Represents a domain error with detailed information about a rule violation or validation failure.
public sealed class DomainError
- Inheritance
-
DomainError
- Inherited Members
Properties
Code
Gets the error code identifying the type of error.
public required string Code { get; init; }
Property Value
Message
Gets the human-readable error message.
public required string Message { get; init; }
Property Value
Metadata
Gets additional metadata associated with this error.
public IReadOnlyDictionary<string, object?> Metadata { get; init; }
Property Value
Severity
Gets the severity level of the error.
public RuleSeverity Severity { get; init; }
Property Value
Tags
Gets the collection of tags associated with this error for categorization.
public IReadOnlyList<string> Tags { get; init; }
Property Value
Target
Gets the target property or path where the error occurred, if applicable.
public string? Target { get; init; }
Property Value
Methods
Create(string, string)
Creates a new domain error with the specified code and message.
public static DomainError Create(string code, string message)
Parameters
Returns
- DomainError
A new domain error instance.
Create(string, string, string)
Creates a new domain error with the specified code, message, and target.
public static DomainError Create(string code, string message, string target)
Parameters
codestringThe error code.
messagestringThe error message.
targetstringThe target property or path.
Returns
- DomainError
A new domain error instance.