9#ifndef HEADER_SQLITEPP_EXCEPTION_IFACE_INCLUDED
10#define HEADER_SQLITEPP_EXCEPTION_IFACE_INCLUDED
44 free_message()
noexcept: _free(
nullptr) {}
45 free_message(
void (*free)(
void *))
noexcept: _free(free) {}
47 void operator()(
const char *
message)
const noexcept
48 {
if (_free) _free(
const_cast<char *
>(
message)); }
50 explicit operator bool()
const noexcept
51 {
return _free !=
nullptr; }
53 void (*_free)(
void *);
81 error(error_code, db.get())
85 error(error_code, &db)
94 _error_code(error_code),
95 _message(std::move(error_message))
99 _error_code(src._error_code),
100 _message(src._message.get_deleter() ? copy_message(src._message.get()) :
message_ptr(src._message.get()))
103 _error_code(src._error_code),
104 _message(std::move(src._message))
106 ~error() noexcept = default;
114 friend void swap(
error & lhs,
error & rhs)
noexcept
117 swap(lhs._error_code, rhs._error_code);
118 swap(lhs._message, rhs._message);
123 {
return _error_code; }
126 {
return _error_code & 0x0FF; }
129 {
return _system_error_code; }
132 {
return _message.
get(); }
141 {
return std::move(_message); }
149 {
return std::move(_message); }
151 static message_ptr copy_message(
const char * src)
noexcept;
154 int _system_error_code = 0;
170 _error(std::move(err))
184 _error(error_code, db)
188 _error(error_code, db)
192 _error(error_code, db)
197 _error(error_code, std::move(message))
208 {
return _error.
system(); }
220 {
return std::move(_error); }
228 const char *
what() const noexcept override;
236 inline
int int_size(
size_t size)
Database Connection.
Definition database_iface.hpp:108
Carries information about SQLite error.
Definition exception_iface.hpp:38
int primary() const noexcept
Returns primary error code part.
Definition exception_iface.hpp:125
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:84
int extended() const noexcept
Returns full extended error code.
Definition exception_iface.hpp:122
message_ptr extract_message() &&noexcept
Move the message out of this object.
Definition exception_iface.hpp:148
const char * message() const noexcept
Returns error message or nullptr, if not available.
Definition exception_iface.hpp:131
std::unique_ptr< const char, free_message > message_ptr
An owning pointer to SQLite error message.
Definition exception_iface.hpp:58
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:80
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:140
int system() const noexcept
Returns system errno error code, if available.
Definition exception_iface.hpp:128
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:93
Exception used to report any SQLite errors.
Definition exception_iface.hpp:166
int system_error_code() const noexcept
Returns system errno error code of the stored error, if available.
Definition exception_iface.hpp:207
exception(int error_code, error::message_ptr &&message) noexcept
Constructs an instance with a given error code and message.
Definition exception_iface.hpp:196
int extended_error_code() const noexcept
Returns full extended error code of the stored error.
Definition exception_iface.hpp:201
exception(class error &&err) noexcept
Constructs an instance by moving an error in.
Definition exception_iface.hpp:169
exception(int error_code, const database *db) noexcept
Constructs an instance from the last error reported from a database.
Definition exception_iface.hpp:183
exception(int error_code) noexcept
Constructs an instance from database independent error code.
Definition exception_iface.hpp:178
class error & error() &noexcept
Returns the stored error.
Definition exception_iface.hpp:215
exception(const class error &err) noexcept
Constructs an instance by copying an error.
Definition exception_iface.hpp:173
int primary_error_code() const noexcept
Returns primary error code part of the stored error.
Definition exception_iface.hpp:204
class error && error() &&noexcept
Returns the stored error.
Definition exception_iface.hpp:219
const char * what() const noexcept override
Returns error message.
const class error & error() const &noexcept
Returns the stored error.
Definition exception_iface.hpp:211
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:191
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:187
ThinSQLite++ namespace.
Definition backup_iface.hpp:17