Base error class for domain-related errors.

DomainError represents violations of business rules or domain invariants. Unlike technical errors, domain errors are expected and should be handled gracefully.

throw new DomainError('INVALID_EMAIL', 'Email format is invalid');

Hierarchy

  • Error
    • DomainError

Constructors

Methods

Properties

Constructors

  • Creates a new DomainError.

    Parameters

    • code: string

      A unique error code for programmatic handling

    • message: string

      A human-readable error message

    Returns DomainError

Methods

  • Returns a JSON representation of this error.

    Returns { code: string; message: string; name: string }

Properties

code: string

A unique error code for programmatic handling