loom.core.errors¶
- exception loom.core.errors.Conflict(message)[source]¶
Bases:
DomainErrorRaised when an operation conflicts with existing state.
- Parameters:
message (str) – Description of the conflicting condition.
- Return type:
None
- exception loom.core.errors.DomainError(message, *, code)[source]¶
Bases:
LoomErrorBase class for all business-logic errors.
Raised inside UseCase execution. Transport adapters catch and convert these to their own error representations.
- exception loom.core.errors.Forbidden(message='Forbidden', *, reason=None, missing=())[source]¶
Bases:
DomainErrorRaised when an action is not permitted for the caller.
- Parameters:
message (str) – Description of the access restriction.
reason (str | None) – Optional machine-readable cause a client can act on, such as
"mfa_required".Nonewhen the refusal has no specific cause.missing (Iterable[str]) – The permissions the caller lacks, in the order given; empty when the authorizer does not tell them.
- Return type:
None
Both are keyword-only and public: the REST adapter puts them in the 403 body. Never put token claims, tenant data or anything the caller may not learn in them; leave them out where the refusal must not become an oracle for the policy.
- Raises:
ValueError – If
reasonis not a non-blank string,missingis a singlestrorbytes, or an item ofmissingis not a non-blank string.- Parameters:
- Return type:
None
- exception loom.core.errors.LoomError(message, *, code)[source]¶
Bases:
ExceptionBase class for all framework errors.
Carries a machine-readable
codeused by transport adapters to produce appropriate responses (HTTP status, dead-letter routing, etc.) without coupling the domain to any transport layer.- Parameters:
- Return type:
None
Example:
raise NotFound("User", id=42)
- exception loom.core.errors.NotFound(entity, *, id)[source]¶
Bases:
DomainErrorRaised when a requested entity does not exist.
Emitted automatically by
LoadStepwhen a repository returnsNone. May also be raised explicitly insideexecutefor semantic not-found conditions.- Parameters:
entity (str) – Name of the missing entity type (e.g.
"User").id (Any) – Lookup key that yielded no result.
- Return type:
None
Example:
raise NotFound("User", id=42)
- exception loom.core.errors.SystemError(message)[source]¶
Bases:
LoomErrorBase class for infrastructure and unexpected errors.
Raised when a repository, external service, or internal subsystem fails. Transport adapters may retry on SystemError and dead-letter on DomainError.
- Parameters:
message (str) – Description of the system failure.
- Return type:
None
- exception loom.core.errors.Unauthenticated(message='Authentication required')[source]¶
Bases:
DomainErrorRaised when an action requires a verified caller and there is none.
Distinct from
Forbidden: the caller can fix anUnauthenticatedby presenting credentials, but cannot fix aForbiddenat all. Transport adapters map it to401with an authentication challenge.- Parameters:
message (str) – Description of the missing authentication.
- Return type:
None
Example:
raise Unauthenticated("This endpoint requires an authenticated caller.")