ThinSQLite++
A thin, safe and convenient modern C++ wrapper for SQLite API.
Loading...
Searching...
No Matches
error Class Reference

Carries information about SQLite error. More...

Public Types

using message_ptr = std::unique_ptr<const char, free_message>
 An owning pointer to SQLite error message.
 

Public Member Functions

 error (int error_code) noexcept
 Constructs an instance from database independent error code.
 
 error (int error_code, const database *db) noexcept
 Constructs an instance from the last error reported from a database.
 
 error (int error_code, const std::unique_ptr< database > &db) noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
 error (int error_code, const database &db) noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
 error (int error_code, message_ptr &&error_message) noexcept
 Constructs an instance with a given error code and message.
 
 error (const error &src) noexcept
 
 error (error &&src) noexcept
 
erroroperator= (error src) noexcept
 
int extended () const noexcept
 Returns full extended error code.
 
int primary () const noexcept
 Returns primary error code part.
 
int system () const noexcept
 Returns system errno error code, if available.
 
const char * message () const noexcept
 Returns error message or nullptr, if not available.
 
message_ptr extract_message () &noexcept
 Move the message out of this object.
 
message_ptr extract_message () &&noexcept
 Move the message out of this object.
 

Friends

class exception
 
void swap (error &lhs, error &rhs) noexcept
 

Detailed Description

Carries information about SQLite error.

The error class stores SQLite error code, possibly associated system errno error code (see sqlite3_system_errno) and an error message, if available.

#include <thinsqlitepp/exception.hpp>

Constructor & Destructor Documentation

◆ error() [1/3]

error ( int error_code)
noexcept

Constructs an instance from database independent error code.

The error message is obtained via sqlite3_errstr

◆ error() [2/3]

error ( int error_code,
const database * db )
noexcept

Constructs an instance from the last error reported from a database.

The error message is obtained via sqlite3_errmsg.

This constructor tries to discover the full extended error via sqlite3_extended_errcode. The error_code argument is currently only used if it is SQLITE_MISUSE.

◆ error() [3/3]

error ( int error_code,
message_ptr && error_message )
inlinenoexcept

Constructs an instance with a given error code and message.

No SQLite calls are performed for this constructor

Member Function Documentation

◆ extract_message() [1/2]

message_ptr extract_message ( ) &
inlinenoexcept

Move the message out of this object.

This allows returning messages to SQLite from callbacks without allocating a copy

◆ extract_message() [2/2]

message_ptr extract_message ( ) &&
inlinenoexcept

Move the message out of this object.

This allows returning messages to SQLite from callbacks without allocating a copy