Exception class for SQL related errors.
Thrown for API and SQL errors. Inherits from std::runtime_error.
The error_code member provides the native error code from the underlying database, enabling programmatic error handling such as retry logic for deadlocks or special handling for constraint violations. Error codes are database-specific:
Example (PostgreSQL):
For MySQL, SQLite, and Oracle, include the respective database header with error codes or use numeric codes directly.
Public Member Functions | |
| sql_exception (const char *msg="SQLException", int code=0) | |
| Constructs a new sql_exception. | |
|
explicit |
Constructs a new sql_exception.
| msg | Error message (defaults to "SQLException") |
| code | Database-specific error code (defaults to 0) |
| const int error_code |
Native error code from the underlying database.
The value is 0 if no specific error code was provided. Consult your database's documentation for code meanings.
Copyright © Tildeslash Ltd. All rights reserved.