exceptions

exception advanced_alchemy.exceptions.AdvancedAlchemyError[source]

Bases: Exception

Base exception class from which all Advanced Alchemy exceptions inherit.

__init__(*args: Any, detail: str = '') None[source]

Initialize AdvancedAlchemyException.

Parameters:
  • *args – args are converted to str before passing to Exception

  • detail – detail of the exception.

exception advanced_alchemy.exceptions.MissingDependencyError[source]

Bases: AdvancedAlchemyError, ImportError

Missing optional dependency.

This exception is raised only when a module depends on a dependency that has not been installed.

__init__(package: str, install_package: str | None = None) None[source]

Initialize AdvancedAlchemyException.

Parameters:
  • *args – args are converted to str before passing to Exception

  • detail – detail of the exception.

exception advanced_alchemy.exceptions.ImproperConfigurationError[source]

Bases: AdvancedAlchemyError

Improper Configuration error.

This exception is raised only when a module depends on a dependency that has not been installed.

exception advanced_alchemy.exceptions.SerializationError[source]

Bases: AdvancedAlchemyError

Encoding or decoding of an object failed.

exception advanced_alchemy.exceptions.RepositoryError[source]

Bases: AdvancedAlchemyError

Base repository exception type.

exception advanced_alchemy.exceptions.ConflictError[source]

Bases: RepositoryError

Data integrity error.

__init__(*args: Any, detail: str = '') None[source]

Initialize AdvancedAlchemyException.

Parameters:
  • *args – args are converted to str before passing to Exception

  • detail – detail of the exception.

exception advanced_alchemy.exceptions.IntegrityError[source]

Bases: RepositoryError

Data integrity error.

exception advanced_alchemy.exceptions.DuplicateKeyError[source]

Bases: IntegrityError

Duplicate key error.

exception advanced_alchemy.exceptions.ForeignKeyError[source]

Bases: IntegrityError

Foreign key error.

exception advanced_alchemy.exceptions.NotFoundError[source]

Bases: RepositoryError

An identity does not exist.

exception advanced_alchemy.exceptions.MultipleResultsFoundError[source]

Bases: RepositoryError

A single database result was required but more than one were found.

class advanced_alchemy.exceptions.ErrorMessages[source]

Bases: TypedDict

advanced_alchemy.exceptions.wrap_sqlalchemy_exception(error_messages: ErrorMessages | None = None, dialect_name: str | None = None) Generator[None, None, None][source]

Do something within context to raise a RepositoryError chained from an original SQLAlchemyError.

>>> try:
...     with wrap_sqlalchemy_exception():
...         raise SQLAlchemyError("Original Exception")
... except RepositoryError as exc:
...     print(f"caught repository exception from {type(exc.__context__)}")
...
caught repository exception from <class 'sqlalchemy.exc.SQLAlchemyError'>