cadrumo.core.errors.hierarchy module¶
The Cadrumo exception hierarchy, and the site-health shapes beside it.
Every refusal in the application descends from CadrumoError, so this
module is the root of the error tree rather than a collection of unrelated
classes. It deliberately imports nothing from the error-code registry: the
registry knows about the hierarchy, not the other way round, and keeping the
arrow pointing one way is what lets cadrumo.core.json_contract depend on
the hierarchy without dragging the registry in behind it.
Keeping these classes in their own defining module lets
cadrumo.core.json_contract depend on the hierarchy without loading
registry-owned envelope models.
- class SiteHealthState(*values)[source]¶
Bases:
StrEnumClosed catalogue of layer-neutral AEAT site-health classifications.
- OK¶
- MANTENIMIENTO¶
- WAF_CHALLENGE¶
- RATE_LIMITED¶
- UNREACHABLE¶
- UNKNOWN_ERROR¶
- class SiteHealthEvidenceLike(*args, **kwargs)[source]¶
Bases:
ProtocolStructural view of the evidence block carried by a site-health status.
Declared in
core.errorssoSiteHealthErrorcan type its payload without importing the adapter layer that produces it. The concrete record isadapters.outbound.aeat.browser.site_health_records.SiteHealthEvidence.Members are read-only properties so the protocol matches covariantly: a concrete record may carry narrower member types (e.g.
AnyHttpUrlforurl) and still satisfy the structural view, which a mutable attribute declaration would reject.
- class SiteHealthStatusLike(*args, **kwargs)[source]¶
Bases:
ProtocolStructural view of a detected AEAT site-health classification.
Declared in
core.errorssoSiteHealthErrorcan accept the status without a runtime or type-checking import of the adapter layer. The concrete record isadapters.outbound.aeat.browser.site_health_records.SiteHealthStatus.Members are read-only properties so the protocol matches covariantly: the concrete
SiteHealthStatuscarries a concreteSiteHealthEvidenceforevidence, which satisfies theSiteHealthEvidenceLikeview only when the member is read-only.- property state: SiteHealthState¶
Classified site-health state (e.g. mantenimiento, WAF challenge, rate limit).
- property evidence: SiteHealthEvidenceLike¶
Evidence block used to classify the detected state.
Returns a
SiteHealthEvidenceLikecarrying the URL, HTTP status, and detected markers that drove classification.
- exception CadrumoError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
ExceptionBase exception for all registered Cadrumo errors.
- Parameters:
- Return type:
None
- code¶
Resolve a subclass’s declared code on first access.
Subclasses created before the declared-code catalogue loads are bound lazily; binding stores the code on the subclass itself, which then shadows this descriptor.
- pydantic_validation_boundary(function)[source]¶
Translate registered failures for Pydantic’s validator protocol.
Pydantic turns
ValueErrorandTypeErrorraised by validators into structuredValidationErrorinstances, but it lets arbitrary exception classes escape. Cadrumo validation failures stay registered internally; this small decorator is applied only to validator callbacks that cross that protocol boundary and preserves the registered failure as__cause__of the required builtinValueError.
- exception AuthError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CadrumoErrorBase class for every AEAT authentication boundary failure.
- Parameters:
- Return type:
None
- code¶
- exception AeatLoginAssertionError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
AuthErrorRaised when an AEAT login assertion cannot be produced or trusted.
- Parameters:
- Return type:
None
- code¶
- class TerminalPreconditionErrorMixin(message=None, *, context=None, translated_message=None, precondition_verdict=None)[source]¶
Bases:
GenericCarry one typed terminal verdict without coupling core to application models.
The mixin deliberately stores the verdict as an opaque object: the application owns the concrete
PreconditionVerdictrecord, while core owns this layer-neutral exception transport behavior. It is mixed in ahead of a registered error class so that class keeps its own error code.- Parameters:
- exception CoreError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CadrumoErrorBase error for internal framework and core-primitive failures.
- Parameters:
- Return type:
None
- code¶
- exception InternalInvariantError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CoreErrorRaised when composed production state violates an internal invariant.
- Parameters:
- Return type:
None
- code¶
- exception DecimalFormatError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CoreErrorRaised when
core.decimal.formatting.format_decimal()receives an invalid argument.Replaces the bare
TypeErrorpreviously raised whenvalueisNonebutnone_valuewas not provided.- Parameters:
- Return type:
None
- code¶
- exception RedactionError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CoreErrorRaised when a redaction helper receives an argument of the wrong type.
Replaces bare
TypeErrorpreviously raised bycore.redaction.rules.redact()andcore.redaction.rules.redact_for_cli_output()when passed a non-strargument.- Parameters:
- Return type:
None
- code¶
- exception CoreValidationError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CoreErrorRaised when core primitives or configuration violate invariants.
Pydantic validators translate this registered failure to
ValueErrorat their narrow protocol boundary.- Parameters:
- Return type:
None
- code¶
- exception ProfileAnswerTypeError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CoreValidationErrorRaised when a typed profile-answers field coercion receives an unexpected type.
Lives in
core.errorssocadrumo.domain.user_profile.setup_answers.SetupAnswerscan raise a typed error without importing application-layer wizard modules. Application-layer wizard code raises the narrowerapplication.wizard.errors.WizardAnswerTypeError, which inherits from this class, so callers catching either type continue to work.- Parameters:
- Return type:
None
- code¶
- exception CadrumoObservabilityError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CadrumoErrorBase class for observability-layer errors.
Lives in
core.errors(rather than the leafcore.observabilitysubpackage) so other subpackages can catch it without importing observability internals. Concrete subclasses are declared incore.observability.errors.- Parameters:
- Return type:
None
- code¶
- exception SiteHealthError(*, status)[source]¶
Bases:
CadrumoErrorRaised when AEAT site-health detection classifies a non-OK state.
Carries a
SiteHealthStatusLikepayload describing the detected state (mantenimiento, WAF challenge, rate limit, unreachable, unknown error) together with the evidence used to classify it. The workflow engine catches this error in a typed arm that precedes the generic exception handler so a planned mantenimiento never collapses intoUNHANDLED_EXCEPTION.The error lives in
core.errors(and not in either leaf subpackage) to break the circular import betweenadapters.outbound.aeat.browser(which raises it) andapplication.workflow(which consumes it). The payload is typed through theSiteHealthStatusLikestructural Protocol declared in this module, so no import of the adapter layer occurs at runtime or under type checking — thecore-not-outerboundary is satisfied without an exclusion.- Parameters:
status (SiteHealthStatusLike)
- Return type:
None
- code¶
- exception ActiveProfilePointerError(*, path)[source]¶
Bases:
CoreErrorRaised when the active-profile pointer is present but invalid.
A missing pointer is a clean cold-start state. A present pointer that cannot be parsed, decoded, read, or validated is storage metadata corruption and does not resolve to a root fallback database route.
- Parameters:
path (object)
- Return type:
None
- code¶
- exception NoActiveProfileError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CadrumoErrorRaised when an operation requires an active profile bucket and none is selected.
Bucket-scoped repositories (transaction catalogue, manual ledger, bucket-local aggregation) and the operator-initiated auth/sede flows refuse to operate without an active profile. The active-bucket precedence chain is a core concern (env var > pointer file), so the refusal that gates it lives in the core error taxonomy and is raised by
core.bucket_pointer.require_active_bucket_id(). Callers that surface this to the operator map it to the standardcli.common.errors.no_active_profilemessage.- Parameters:
- Return type:
None
- code¶