cadrumo.adapters.inbound.notificacion.errors module

Error hierarchy for the AEAT notificación document parsers.

An inbound parse-error boundary. The parser refuses rather than degrades: a document whose labels it cannot bind raises SancionParseError naming every field it could not resolve, so an incomplete read can never present as a complete one. Callers inspect the structured attributes rather than the rendered message.

exception NotificacionParseError(message=None, *, context=None, translated_message=None)[source]

Bases: CadrumoError

Root for every failure raised while parsing an AEAT notification document.

Parameters:
  • message (str | None)

  • context (Mapping[str, object] | None)

  • translated_message (str | None)

Return type:

None

code
exception SancionParseError(message=None, *, context=None, translated_message=None, missing=(), malformed=(), ambiguous=())[source]

Bases: NotificacionParseError

Raised when a sanción / liquidación document cannot be fully parsed.

The parser has exactly two outcomes: a complete typed record, or this error. There is no partial record and no zero-filled record, because a figure read off one of these documents is a figure a taxpayer pays or appeals against, and a silently-blank field is indistinguishable from a genuine zero once it leaves the parser.

Variables:
  • missing – Field names whose label could not be located in the document text at all.

  • malformed – Field names whose label was located but whose printed value did not match the AEAT money / percentage shape.

  • ambiguous – Field names whose label matched more than one distinct printed value, so no single reading is defensible.

Parameters:
Return type:

None

code
exception SancionArithmeticError(message=None, *, context=None, translated_message=None, missing=(), malformed=(), ambiguous=())[source]

Bases: SancionParseError

Raised when the printed lines of a parsed sanción do not reconcile.

This is a check on the PARSE, not on AEAT’s arithmetic. Every figure here is printed on the same document, so sanción resultante minus the printed reducciones must equal the printed diferencia to the cent. A divergence means a label was bound to the wrong number — the failure mode that would otherwise hand an operator a confidently wrong figure — so it refuses instead of returning the record.

Parameters:
Return type:

None

code