Reference: Exceptions¶
DuoORM defines a set of custom exceptions that inherit from a base DuoOrmError. This allows you to write try...except blocks that specifically target errors raised by the ORM.
This module contains the set of custom exceptions raised by DuoORM.
Having custom exceptions allows users of the library to reliably catch errors specific to the ORM's operation, rather than generic Python errors.
ConfigurationError ¶
Bases: DuoOrmError
Raised when there is a problem with the ORM's configuration.
For example, if a required configuration file is missing or a database URL is not provided.
DuoOrmError ¶
Bases: Exception
Base exception for all errors raised by DuoORM.
IntegrityError ¶
Bases: DuoOrmError
Raised when a database integrity constraint is violated.
This is a wrapper around the database driver's specific integrity error (e.g., sqlalchemy.exc.IntegrityError) to provide a consistent API. It typically signals a unique constraint violation.
InvalidQueryError ¶
Bases: DuoOrmError
Raised when a query is constructed in an invalid way, for example by passing an unsupported operator.
MultipleObjectsFoundError ¶
Bases: DuoOrmError
Raised when a query that expects a single result finds multiple.
Similar to ObjectNotFoundError, this would be used by .one() or .get().
ObjectNotFoundError ¶
Bases: DuoOrmError
Raised when a query that expects a single result finds none.
For example, a .one() or .get() method would raise this.
UnsupportedOperationError ¶
Bases: InvalidQueryError
Raised when an operation is not supported by the current database dialect.
For example, using JSONContains on a database that does not support JSON.
ValidationError ¶
Bases: DuoOrmError
Raised when model-level validation fails.
Attributes:
| Name | Type | Description |
|---|---|---|
field |
str | None
|
Optional field name associated with the error. |
detail |
Any
|
Optional structured detail for the error. |