Source code for cadrumo.adapters.outbound.aeat.auth.errors

"""Shared exception taxonomy for outbound AEAT authentication.

Every class here inherits from :class:`~core.errors.hierarchy.CadrumoError`, so the
core error registry binds a stable :class:`~core.errors.error_codes.ErrorCode` and
locale message key to the public auth failure surface. Certificate and Cl@ve
Móvil providers raise these errors with ``translated_message`` keys when a
provider precondition, verification probe, persisted-session check, or
configuration guard refuses to continue.

See Also:
    :mod:`adapters.outbound.aeat.auth` for the public auth surface,
    :class:`~application.auth.session_types.AeatSession` for successful live
    sessions, and :class:`~application.auth.session_types.AeatLoginAssertion`
    for verification outcomes that can be returned without raising.
"""

from __future__ import annotations

from .....core.errors.hierarchy import AuthError


[docs] class AuthConfigurationError(AuthError): """Raised when required authentication settings are missing or malformed. This covers provider selection and configuration refusals before browser or certificate work begins. Provider-specific subclasses such as :class:`adapters.outbound.aeat.auth.clave_movil_support.ClaveMovilConfigurationError` keep their own public identity while remaining catchable through this shared configuration arm. """
[docs] class AuthProviderCleanupError(AuthError): """Raised when an auth provider retains browser resources after close."""
[docs] class AuthValidationError(AuthError): """Raised when authentication parameters or field values fail domain validation. Auth helpers raise the registered type directly. Any future Pydantic callback that needs this refusal must translate it to a plain ``ValueError`` at that callback boundary rather than adding a builtin base here. """
[docs] class AeatSessionExpiredError(AuthError): """Raised when an authenticated AEAT session is no longer usable. Conditions feeding this error include an :class:`~application.auth.session_types.AeatSession` idle deadline that has elapsed, a failed single-shot reauthentication attempt, or an HTTP 401/403 surfaced by a downstream live-read call site. The registered error code is retryable so operator flows can prompt for a fresh authentication attempt. """
__all__ = [ "AeatSessionExpiredError", "AuthConfigurationError", "AuthProviderCleanupError", "AuthValidationError", ]