Exceptions topic

All exceptions thrown by package:typed_sql subclass DatabaseException, the inheritance hierarchy for DatabaseException is as follows:

As evident from the hierarchy above we have 3 general classes of exceptions:

The OperationException implies that some query or operation you asked the database failed. This is typically a constraint violation, division by zero, invalid cast or some other runtime issue that couldn't be detected before the query (or operation) was executed.

Warning

Database adapters may throw UnspecifiedOperationException for any error, even when a more specific exception is exists. This means that if you catch a DivisionByZeroException then you know the problem was division by zero. But if you catch a UnspecifiedOperationException then the problem could be division by zero, or some other problem.

Database adapters may throw UnspecifiedOperationException when a query fails due to division by zero, even if DivisionByZeroException is more specific.

The TransactionAbortedException is thrown by db.transact() when a transaction is rolled backed. The TransactionAbortedException.reason property holds the Exception that caused the transaction to be aborted.

This could be an Exception you threw inside the transaction callback, or it could be an OperationException caused by one of the queries or operations inside the transaction. See Transactions, for details on how recover from aborted an transaction.

The DatabaseConnectionException is thrown when there is a problem with the connection to the database. It could be that database is down, that a TCP connection to the database was dropped, or that the database connection is simply misconfigured.

Exceptions / Errors

AuthenticationException Exceptions
Thrown when authentication with the database failed.
ConstraintViolationException Exceptions
Thrown when an operation was aborted because a constraint violation in the database.
DatabaseConnectionBrokenException Exceptions
Thrown when the database connection was broken.
DatabaseConnectionException Exceptions
Thrown when there is an issue with the database connection.
DatabaseConnectionForceClosedException Exceptions
Thrown when the database connection is force closed.
DatabaseConnectionRefusedException Exceptions
Thrown when the database connection was refused.
DatabaseConnectionTimeoutException Exceptions
Thrown when a connection timeout happened.
DatabaseException Exceptions
Base class for all exceptions thrown by package:typed_sql.
DivisionByZeroException Exceptions
Thrown when a division by zero happened in the database.
IntermittentConnectionException Exceptions
Thrown when there is an intermittent issue with the database connection.
OperationException Exceptions
Thrown when the database reports an error while executing an operation.
TransactionAbortedException Exceptions
Thrown when a transaction was rolled back.
TypeCastException Exceptions
Thrown when an SQL type cast fail in the database.
UnspecifiedOperationException Exceptions
An unspecified OperationException.