9#ifndef HEADER_SQLITEPP_EXCEPTION_IFACE_INCLUDED
10#define HEADER_SQLITEPP_EXCEPTION_IFACE_INCLUDED
40 friend class exception;
45 free_message()
noexcept: _free(
nullptr) {}
46 free_message(
void (*free)(
void *))
noexcept: _free(free) {}
48 void operator()(
const char *
message)
const noexcept
49 {
if (_free) _free(
const_cast<char *
>(
message)); }
51 explicit operator bool()
const noexcept
52 {
return _free !=
nullptr; }
54 void (*_free)(
void *);
82 error(error_code, db.get())
86 error(error_code, &db)
95 _error_code(error_code),
96 _message(std::move(error_message))
100 _error_code(src._error_code),
101 _message(src._message.get_deleter() ? copy_message(src._message.get()) :
message_ptr(src._message.get()))
104 _error_code(src._error_code),
105 _message(std::move(src._message))
107 ~error() noexcept = default;
115 friend void swap(
error & lhs,
error & rhs)
noexcept
118 swap(lhs._error_code, rhs._error_code);
119 swap(lhs._message, rhs._message);
124 {
return _error_code; }
127 {
return _error_code & 0x0FF; }
130 {
return _system_error_code; }
133 {
return _message.get(); }
134 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 38, 0)
151 {
return std::move(_message); }
159 {
return std::move(_message); }
161 static message_ptr copy_message(
const char * src)
noexcept;
164 int _system_error_code = 0;
165 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 38, 0)
184 _error(std::move(err))
198 _error(error_code, db)
202 _error(error_code, db)
206 _error(error_code, db)
211 _error(error_code, std::move(message))
216 {
return _error.extended(); }
219 {
return _error.primary(); }
222 {
return _error.system(); }
234 {
return std::move(_error); }
242 const char *
what() const noexcept override;
250 inline
int int_size(
size_t size)
Database Connection.
Definition database_iface.hpp:109
Carries information about SQLite error.
Definition exception_iface.hpp:39
int primary() const noexcept
Returns primary error code part.
Definition exception_iface.hpp:126
error(int error_code, const database &db) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition exception_iface.hpp:85
int extended() const noexcept
Returns full extended error code.
Definition exception_iface.hpp:123
message_ptr extract_message() &&noexcept
Move the message out of this object.
Definition exception_iface.hpp:158
const char * message() const noexcept
Returns error message or nullptr, if not available.
Definition exception_iface.hpp:132
int offset() const noexcept
Returns the offset within SQL statement that produced the error.
Definition exception_iface.hpp:140
std::unique_ptr< const char, free_message > message_ptr
An owning pointer to SQLite error message.
Definition exception_iface.hpp:59
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 o...
Definition exception_iface.hpp:81
error(int error_code) noexcept
Constructs an instance from database independent error code.
message_ptr extract_message() &noexcept
Move the message out of this object.
Definition exception_iface.hpp:150
int system() const noexcept
Returns system errno error code, if available.
Definition exception_iface.hpp:129
error(int error_code, const database *db) noexcept
Constructs an instance from the last error reported from a database.
error(int error_code, message_ptr &&error_message) noexcept
Constructs an instance with a given error code and message.
Definition exception_iface.hpp:94
Exception used to report any SQLite errors.
Definition exception_iface.hpp:180
int system_error_code() const noexcept
Returns system errno error code of the stored error, if available.
Definition exception_iface.hpp:221
exception(int error_code, error::message_ptr &&message) noexcept
Constructs an instance with a given error code and message.
Definition exception_iface.hpp:210
int extended_error_code() const noexcept
Returns full extended error code of the stored error.
Definition exception_iface.hpp:215
exception(class error &&err) noexcept
Constructs an instance by moving an error in.
Definition exception_iface.hpp:183
exception(int error_code, const database *db) noexcept
Constructs an instance from the last error reported from a database.
Definition exception_iface.hpp:197
exception(int error_code) noexcept
Constructs an instance from database independent error code.
Definition exception_iface.hpp:192
class error & error() &noexcept
Returns the stored error.
Definition exception_iface.hpp:229
exception(const class error &err) noexcept
Constructs an instance by copying an error.
Definition exception_iface.hpp:187
int primary_error_code() const noexcept
Returns primary error code part of the stored error.
Definition exception_iface.hpp:218
class error && error() &&noexcept
Returns the stored error.
Definition exception_iface.hpp:233
const char * what() const noexcept override
Returns error message.
const class error & error() const &noexcept
Returns the stored error.
Definition exception_iface.hpp:225
exception(int error_code, const database &db) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition exception_iface.hpp:205
exception(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 o...
Definition exception_iface.hpp:201
ThinSQLite++ namespace.
Definition backup_iface.hpp:17