Errors¶
Foundation provides a structured error model — every failure carries a message, metadata, and a typed identity.
Core types¶
- Error — Base class. Carries an
ErrorMessageandErrorMetadata. - ErrorMessage — A value object representing the human-readable description.
- ErrorMetadata — Context dict for extra fields (field name, detail, codes).
- FieldReference — A value object referencing a field by name (
value: str).
Concrete error types¶
Validation¶
- ValidationError — Abstract base for validation failures. Not meant to be thrown directly.
- ValidationFailedError — Concrete validation error. The type to raise when input validation fails.
- FieldErrors — Groups errors by field. Carries a
FieldReferenceand child errors. - CombinedErrors — Groups multiple errors from different sources.
- ValidationFieldErrors — Groups validation errors for a specific field. Carries a
FieldReferenceand child errors. - CombinedValidationErrors — Groups multiple validation errors that share the
ValueErrorMixintaxonomy.
Rule violations¶
- RuleViolationError — Abstract base for business rule failures. Not meant to be thrown directly.
- RuleViolatedError — Concrete rule violation error. The type to raise when a business rule is violated.
- CombinedRuleViolationErrors — Groups multiple rule violation errors that share the
RuntimeErrorMixintaxonomy.
Structural errors¶
- ArchitectureError — Raised when a structural invariant of the architecture is violated.
- CantModifyImmutableAttributeError — Raised when a frozen attribute is reassigned.
- ConfigurationError — Raised when configuration is invalid.
- NoneNotAllowedError — Raised when
Noneis provided where disallowed. - NonHashableValueError — Raised when a non-hashable value is provided where hashability is required.
- NotCallablePredicateError — Raised when a specification predicate is not callable.
- ResultAccessError — Raised when accessing
valueonErrorerroronOk.
Built-in taxonomy¶
Concrete errors include mixins that make them catchable as Python built-in types:
-
ValueError— Input and precondition errors inheritValueErrorMixin:
ValidationFailedError,ConfigurationError,NoneNotAllowedError,
NonHashableValueError,NotCallablePredicateError,
ValidationFieldErrors,CombinedValidationErrors -
RuntimeError— State and invariant errors inheritRuntimeErrorMixin:
RuleViolatedError,ArchitectureError,
CantModifyImmutableAttributeError,ResultAccessError,
CombinedRuleViolationErrors
The root Error class does not include either mixin. Domain and application
errors inherit the mixin from the appropriate base class — see their reference
pages for details.
When to use¶
Subclass Error for your own error types. Raise ValidationFailedError for input failures, RuleViolatedError for business rule violations. Use FieldErrors and CombinedErrors to group multiple failures. Every error carries an ErrorMessage and ErrorMetadata for structured handling.
Related
See Domain Errors and Application Errors for block-specific error types.