Table of Contents

Class DomainError

Namespace
FunctionalDdd
Assembly
FunctionalDdd.RailwayOrientedProgramming.dll

Represents a domain or business rule violation. Use this for errors that occur when domain logic or business rules prevent an operation from completing. Maps to HTTP 422 Unprocessable Entity.

public sealed class DomainError : Error, IEquatable<Error>
Inheritance
DomainError
Implements
Inherited Members
Extension Methods

Examples

// Business rule violations
Error.Domain("Cannot withdraw more than account balance")
Error.Domain("Minimum order quantity is 10 units")
Error.Domain("Cannot cancel order after shipment has begun")
Error.Domain("Discount percentage cannot exceed maximum allowed limit")

Remarks

This is distinct from validation errors (field-level data problems) and conflicts (state-based collisions). Domain errors represent semantic violations of business invariants that cannot be expressed as simple field validation.

Constructors

DomainError(string, string, string?)

Initializes a new instance of the DomainError class.

public DomainError(string detail, string code, string? instance = null)

Parameters

detail string

Description of the business rule that was violated.

code string

The error code identifying this type of domain error.

instance string

Optional identifier for the entity or operation.