SQLiteXX  0.1.0
 All Classes Namespaces Files Functions Enumerations Enumerator
Exception.h
Go to the documentation of this file.
1 
3 #ifndef __SQLITEXX_SQLITE_EXCEPTION_H__
4 #define __SQLITEXX_SQLITE_EXCEPTION_H__
5 
6 #include <sqlite3.h>
7 
8 #include <stdexcept>
9 #include <string>
10 
11 namespace sqlite
12 {
14  class exception : public std::runtime_error
15  {
16  public:
17 
18  const int errcode;
19  const std::string message;
20 
21  explicit exception(sqlite3 * const connection) :
22  std::runtime_error(sqlite3_errmsg(connection)),
23  errcode(sqlite3_extended_errcode(connection)),
24  message(sqlite3_errmsg(connection))
25  {}
26 
27  explicit exception(const int code, const std::string& message) :
28  std::runtime_error(message),
29  errcode(code),
30  message(message)
31  {}
32  };
33 
35  class busy_exception: public exception
36  {
37  public:
38  explicit busy_exception(sqlite3 * const connection) :
39  exception(connection)
40  {}
41 
42  explicit busy_exception(const std::string& message) :
43  exception(SQLITE_BUSY, message)
44  {}
45  };
46 
47  class SQLiteXXException: public std::runtime_error
48  {
49  public:
50  explicit SQLiteXXException(const std::string& message) :
51  std::runtime_error(message)
52  {}
53  };
54 
55 
56  void throw_error_code(sqlite3 *connection);
57  void throw_error_code(const int errcode, const std::string& message);
58 }
59 
60 #endif
61 
Encapsulation of the SQLITE_BUSY error code derived from SQLite::Exception.
Definition: Exception.h:35
Encapsulation of the error code and message from SQLite3, based on std::runtime_error.
Definition: Exception.h:14