Exceptions

nextorm exception hierarchy.

exception nextorm.exceptions.MappingError[source]

Bases: Exception

Raised when entity relation wiring is invalid or ambiguous.

Thrown by generate_mapping() when:

  • A Set[T] attribute has no matching back-reference on T.

  • Multiple relations between the same two entities exist without an explicit reverse= attribute to resolve the ambiguity.

exception nextorm.exceptions.ObjectNotFound[source]

Bases: Exception

Raised by get_or_raise() when no row matches.

Example:

user = db.select(User).filter(User.id == 99).get_or_raise()
# → ObjectNotFound: User matching the given filter was not found.
exception nextorm.exceptions.MultipleObjectsFoundError[source]

Bases: Exception

Raised by get() or get_or_raise() when more than one row matches.

Example:

# Multiple users named "alice"
user = db.select(User).filter(User.name == "alice").get()
# → MultipleObjectsFoundError: get() returned more than one User.
exception nextorm.exceptions.ConstraintError[source]

Bases: Exception

Raised when a database constraint (UNIQUE, NOT NULL, FK) is violated.

Wraps the underlying DBAPI IntegrityError so callers can catch a provider-independent exception type.

exception nextorm.exceptions.TransactionError[source]

Bases: Exception

Raised for transaction-level problems (deadlock, serialization failure, session-is-over, etc.).

exception nextorm.exceptions.OptimisticCheckError[source]

Bases: Exception

Raised when an optimistic version check fails on UPDATE.

A version check fails when the row’s current version in the database no longer matches the version the entity was loaded with — meaning another transaction updated the row concurrently.

Example:

alice = db.select(Article).filter(Article.id == 1).fetch_one()
# ... another transaction updates article 1 and bumps its version ...
alice.title = "New title"
db.save(alice)  # → OptimisticCheckError: concurrent update detected
exception nextorm.exceptions.CommitException[source]

Bases: TransactionError

Raised when the primary-database commit fails during a staged commit.

The exceptions attribute contains the list of underlying exceptions that were collected (primary failure first, then any rollback failures).

When this is raised all secondary databases have been rolled back.

__init__(msg, exceptions)[source]
Parameters:
Return type:

None

exception nextorm.exceptions.PartialCommitException[source]

Bases: TransactionError

Raised when the primary database committed but one or more secondary databases failed.

The primary database’s work is durable; the secondary failures are collected in exceptions. Manual reconciliation may be required.

__init__(msg, exceptions)[source]
Parameters:
Return type:

None