"""Domain exceptions for the invoice catalogue.Defines the typed error hierarchy raised by :mod:`aeat.domain.invoices`.Every failure path inherits from :class:`InvoiceError` so callers cancatch the whole domain, while :class:`InvoiceCatalogueError` and itssubclasses narrow to catalogue-level faults (persistence, missingrecords, broken cross-catalogue links)."""from__future__importannotationsfrompathlibimportPathfrom...core.errorsimportAeatError,CoreValidationError__all__=["InvoiceCatalogueError","InvoiceError","InvoiceLinkError","InvoiceLinkInconsistencyError","InvoiceNotFoundError","InvoicePersistenceError","InvoiceValidationError",]
[docs]classInvoiceError(AeatError):"""Base error for every invoice-catalogue failure."""
[docs]classInvoiceCatalogueError(InvoiceError):"""Raised when an invoice catalogue is invalid or inconsistent."""
[docs]classInvoicePersistenceError(InvoiceCatalogueError):"""Raised when invoice catalogue persistence cannot be completed."""
[docs]classInvoiceNotFoundError(InvoiceCatalogueError):"""Raised when a catalogue lookup targets a missing invoice."""
[docs]classInvoiceLinkError(InvoiceCatalogueError):"""Raised when a bidirectional invoice/transaction link cannot proceed."""
[docs]classInvoiceLinkInconsistencyError(InvoiceLinkError):"""Raised when a bidirectional link leaves the two catalogues out of sync. Carries both filesystem paths and both identifiers so an operator can manually reconcile the invoice and transaction catalogues. Attributes: invoice_path: Path to the invoice catalogue file. transactions_path: Path to the transaction catalogue file. invoice_id: Invoice identifier involved in the failed link. transaction_id: Transaction identifier involved in the failed link. """def__init__(self,*,invoice_path:Path,transactions_path:Path,invoice_id:str,transaction_id:str,message:str,)->None:"""Construct a link-inconsistency error carrying both sides of the failure. Args: invoice_path: Path to the invoice catalogue file. transactions_path: Path to the transaction catalogue file. invoice_id: Invoice identifier involved in the failed link. transaction_id: Transaction identifier involved in the failed link. message: Human-readable explanation. """super().__init__(message)self.invoice_path:Path=invoice_pathself.transactions_path:Path=transactions_pathself.invoice_id:str=invoice_idself.transaction_id:str=transaction_id
[docs]classInvoiceValidationError(InvoiceError,CoreValidationError):"""Raised when invoice records violate state or shape invariants. Inherits from CoreValidationError (which itself inherits from CoreError and ValueError) to participate in the shared CoreValidationError catch surface and remain compatible with pydantic validators. """