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'); Copy
throw new DomainError('INVALID_EMAIL', 'Email format is invalid');
Creates a new DomainError.
A unique error code for programmatic handling
A human-readable error message
Returns a JSON representation of this error.
Readonly
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.
Example