Lightweight 0.20261105.1
Loading...
Searching...
No Matches
Diagnostics.hpp File Reference
#include "../../Api.hpp"
#include "../../SqlError.hpp"
#include <string_view>

Go to the source code of this file.

Functions

LIGHTWEIGHT_API std::string_view Lightweight::Driver::Sqlite3::SqlStateFromResultCode (int extendedResultCode, std::string_view message) noexcept
 The SQLSTATE of a SQLite failure.
 
LIGHTWEIGHT_API SqlErrorInfo Lightweight::Driver::Sqlite3::MakeErrorInfo (int extendedResultCode, std::string_view message)
 The diagnostics of a SQLite failure.
 

Detailed Description

The diagnostics of the SQLite3 driver: how a SQLite result code becomes a Lightweight::SqlErrorInfo.

SQLite reports a result code and a message, no SQLSTATE. The driver derives one from a descriptor table, so the library's error classification (SqlErrorDetection.hpp, the retry policies) answers for the native driver as it does for an ODBC driver: constraint violations land in class 23, a busy or locked database in the retryable 40001, a failed open in HY000.

Definition in file Diagnostics.hpp.

Function Documentation

◆ SqlStateFromResultCode()

LIGHTWEIGHT_API std::string_view Lightweight::Driver::Sqlite3::SqlStateFromResultCode ( int  extendedResultCode,
std::string_view  message 
)
noexcept

The SQLSTATE of a SQLite failure.

Looked up in a table ordered most specific first: a row matches the full extended result code, or only its primary code (the low 8 bits) where the row says so; the rows for SQLITE_ERROR also look for a fragment of SQLite's message ("no such table", "no such column", "already exists", "syntax error"), since SQLite reports those with no more specific code.

Parameters
extendedResultCodeThe extended result code of the failure.
messageSQLite's message for it.
Returns
The SQLSTATE of the first matching row; "HY000" when no row matches.

References Lightweight::Driver::Sqlite3::SqlStateFromResultCode().

Referenced by Lightweight::Driver::Sqlite3::SqlStateFromResultCode().

◆ MakeErrorInfo()

LIGHTWEIGHT_API SqlErrorInfo Lightweight::Driver::Sqlite3::MakeErrorInfo ( int  extendedResultCode,
std::string_view  message 
)

The diagnostics of a SQLite failure.

Parameters
extendedResultCodeThe extended result code of the failure; it becomes the native error code.
messageSQLite's message for it, verbatim.
Returns
The diagnostics, with the SQLSTATE of SqlStateFromResultCode.

References Lightweight::Driver::Sqlite3::MakeErrorInfo().

Referenced by Lightweight::Driver::Sqlite3::MakeErrorInfo().