ExceptionTranslator

A specialized translator that converts low-level database exceptions into a structured hierarchy of Octavius DatabaseExceptions.

This component is central to the "Fail-Safe SQL" philosophy of the framework. It categorizes SQLExceptions and PostgreSQL-specific PSQLExceptions based on their SQLSTATE error codes, providing developers with actionable, high-level information about:

  • Integrity Violations: Unique, Foreign Key, Not Null, and Check constraints.

  • Statement Errors: Syntax errors, permission denied, or missing objects (tables/columns).

  • Concurrency Issues: Deadlocks and lock timeouts.

  • Connection Problems: Pool exhaustion, server disconnection, or resource limits.

Each translated exception is enriched with a QueryContext, which includes the original SQL statement and its parameters, making debugging and logging significantly more effective.

Functions

Link copied to clipboard

Translates any Throwable into an Octavius DatabaseException. Prioritizes SQLException and its PostgreSQL-specific error codes (SQLSTATE).