core.errors.domain_error¶
src.core.errors.domain_error
¶
Base domain error class for Railway-Oriented Programming.
DomainError is the abstract base class for ALL application errors. Domain errors represent business rule violations and validation failures. They flow through the system as data (Result types), not exceptions.
Architecture: - Base class for all error types (core, domain, infrastructure) - Does NOT inherit from Exception (not raised, returned in Result) - Uses dataclass inheritance (NOT Protocol/ABC) - Type-safe with Result[T, DomainError]
Usage
from src.core.errors import DomainError from src.core.enums import ErrorCode
@dataclass(frozen=True, slots=True, kw_only=True) class MyError(DomainError): pass # Inherits code, message, details
Classes¶
DomainError
dataclass
¶
Base domain error (does NOT inherit from Exception).
Domain errors represent business rule violations and validation failures. They flow through the system as data (Result types), not exceptions.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
ErrorCode
|
Machine-readable error code (enum). |
message |
str
|
Human-readable error message. |
details |
dict[str, str] | None
|
Optional context for debugging. |