Source code for aeat.adapters.outbound.llm._errors
"""Error hierarchy for the LLM subpackage.All public LLM exceptions inherit from:class:`~adapters.outbound.llm.LLMError`, which extends:class:`~core.errors.AeatError`. Provider adapters surface:exc:`~adapters.outbound.llm.LLMProviderError` and:exc:`~adapters.outbound.llm.LLMRateLimitError`, cache and usage storagesurface :exc:`~adapters.outbound.llm.LLMCacheError`, and strict modelvalidators surface :exc:`~adapters.outbound.llm.LLMValidationError`."""from__future__importannotationsfrom....core.errorsimportAeatError
[docs]classLLMError(AeatError):"""Base exception for public LLM package failures."""
[docs]classLLMProviderError(LLMError):"""Raised when a provider adapter cannot return a completion."""
[docs]classLLMPdfRasterisationError(LLMError):"""Raised when :func:`~adapters.outbound.llm.rasterise_pdf_pages_to_base64_png` fails."""
[docs]classLLMCacheError(LLMError):"""Raised when :class:`~adapters.outbound.llm.LLMCache` storage fails."""
[docs]classLLMRateLimitError(LLMProviderError):"""Raised when a provider rejects a request because of rate limits. Inherits from :exc:`~adapters.outbound.llm.LLMProviderError` so callers can catch all provider-boundary failures together. Args: message: Human-readable error message. retry_after_seconds: Optional server-provided retry delay in seconds. """def__init__(self,message:str,retry_after_seconds:float|None=None)->None:super().__init__(message)self.retry_after_seconds=retry_after_seconds
[docs]classLLMConfigError(LLMError):"""Raised when :class:`~adapters.outbound.llm.LLMClient` configuration is invalid."""
[docs]classLLMValidationError(LLMError,ValueError):"""Raised when an LLM-related object fails validation. Inherits from both :class:`~adapters.outbound.llm.LLMError` and :class:`ValueError` to remain compatible with Pydantic's validator-failure contract while allowing catch-all :class:`~adapters.outbound.llm.LLMError` handlers to detect integrity failures. """