Skip to content

xtr_orm.exception

Every error this library raises, all deriving from :class:OrmError.

InvalidArgumentError

InvalidArgumentError(reason: str)

Bases: OrmError, ValueError

A configuration or a call was given something the library cannot work with.

Raised where the value is given — a connection without a name, a version table without a name — rather than when a database is first reached.

Also a :class:ValueError, so code that already guards its configuration with except ValueError keeps working without learning a new exception.

Attributes:

  • reason (str) –

    What is wrong with the value.

Record what is wrong with the value.

MigrationError

MigrationError(reason: str)

Bases: OrmError

A migration operation was refused, or its revisions could not be read.

Raised before anything is changed whenever it can be decided up front: a version that no revision answers to, a revision run out of order, a diff against a database that is behind its revisions. Nothing is written when it is raised from a check; a failing revision rolls back what the database lets it.

Attributes:

  • reason (str) –

    Why the operation was refused.

Record why the operation was refused.

MissingDatabaseError

MissingDatabaseError(database: str, operation: str)

Bases: OrmError, FileNotFoundError

A database was dropped that is not there — a SQLite file that does not exist.

Also a :class:FileNotFoundError, as the missing file it stands for is. Ask for if_exists to leave a database that does not exist alone and be told so instead.

Attributes:

  • database (str) –

    The database's name — for SQLite, its file.

  • operation (str) –

    What was asked, such as "drop".

Record which database was asked for what.

OrmError

Bases: Exception

Base class for every error raised by this library.

Catch this to handle anything the library can refuse; catch a subclass to handle one cause. Every subclass carries the data a caller needs as typed attributes and composes its own message from them.

SessionUnavailableError

SessionUnavailableError(connection: str, reason: str)

Bases: OrmError

The session of the current unit of work was asked for where there is none.

A connection reaches the session everything in a unit of work shares — a message's handlers, say — only inside one, and only when it was registered with a way to.

Attributes:

  • connection (str) –

    The connection the session was asked of.

  • reason (str) –

    Why there is none.

Record which connection was asked, and why it has no session to give.

UnknownConnectionError

UnknownConnectionError(name: str, known: tuple[str, ...])

Bases: OrmError, LookupError

A connection was asked for by a name nothing registered.

Also a :class:LookupError, as a missing key in any other mapping is.

Attributes:

  • name (str) –

    The name asked for.

  • known (tuple[str, ...]) –

    Every name that is registered.

Record the name asked for and the ones that exist.

UnsupportedDatabaseError

UnsupportedDatabaseError(backend: str, operation: str)

Bases: OrmError

A database server was asked for something this library cannot do on it.

Creating or dropping a database takes a statement of the server's own; a server whose statement is not known here is refused rather than sent a guess.

Attributes:

  • backend (str) –

    The kind of server the URL names, such as "oracle".

  • operation (str) –

    What was asked, such as "create".

Record which server was asked for what.