bzr branch
http://bzr.ed.am/sqlite3cc
1
by edam
- initial commit |
1 |
/* |
2
by edam
- further initial development |
2 |
* exception.h |
1
by edam
- initial commit |
3 |
* |
22
by edam
updated email and web addresses |
4 |
* Copyright (C) 2009 Tim Marston <tim@ed.am> |
1
by edam
- initial commit |
5 |
* |
2
by edam
- further initial development |
6 |
* This file is part of sqlite3cc (hereafter referred to as "this program"). |
22
by edam
updated email and web addresses |
7 |
* See http://ed.am/dev/sqlite3cc for more information. |
8 |
* |
|
9 |
* This program is free software: you can redistribute it and/or modify it under |
|
10 |
* the terms of the GNU Lesser General Public License as published by the Free |
|
11 |
* Software Foundation, either version 3 of the License, or (at your option) any |
|
12 |
* later version. |
|
13 |
* |
|
14 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
15 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
16 |
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
|
17 |
* details. |
|
1
by edam
- initial commit |
18 |
* |
19 |
* You should have received a copy of the GNU Lesser General Public License |
|
20 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
21 |
*/ |
|
22 |
||
2
by edam
- further initial development |
23 |
#ifndef SQLITE3CC_EXCEPTION_H_ |
24 |
#define SQLITE3CC_EXCEPTION_H_ |
|
1
by edam
- initial commit |
25 |
|
26 |
||
27 |
#include <sqlite3.h> |
|
28 |
#include <stdexcept> |
|
45
by Tim Marston
fixed some missing/incorrect includes |
29 |
#include <string> |
1
by edam
- initial commit |
30 |
|
31 |
||
32 |
namespace sqlite |
|
33 |
{ |
|
34 |
||
35 |
||
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
36 |
class connection; |
13
by edam
- made basic_statement::step() protected, for use by query and command only |
37 |
|
38 |
||
1
by edam
- initial commit |
39 |
/** |
40 |
* Main (base) sqlite exception class. |
|
41 |
*/ |
|
42 |
class sqlite_error |
|
43 |
: |
|
44 |
public std::exception |
|
45 |
{ |
|
46 |
//______________________________________________________________________________ |
|
47 |
// instantiation |
|
48 |
public: |
|
49 |
||
50 |
/** |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
51 |
* Constructor that takes an sqlite result code and a connection from which |
22
by edam
updated email and web addresses |
52 |
* to determine it's error message. |
53 |
* |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
54 |
* @param connection a reference to a connection |
55 |
* @param code the sqlite result code |
|
13
by edam
- made basic_statement::step() protected, for use by query and command only |
56 |
* @see sqlite_errmsg() |
57 |
*/ |
|
58 |
explicit sqlite_error( |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
59 |
connection &connection, |
13
by edam
- made basic_statement::step() protected, for use by query and command only |
60 |
int code ); |
61 |
||
62 |
||
63 |
/** |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
64 |
* Constructor that takes an sqlite result code and determines it's own |
22
by edam
updated email and web addresses |
65 |
* generic error message. |
66 |
* |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
67 |
* @param code the sqlite result code |
1
by edam
- initial commit |
68 |
*/ |
2
by edam
- further initial development |
69 |
explicit sqlite_error( |
9
by edam
- added NEWS |
70 |
int code ); |
1
by edam
- initial commit |
71 |
|
72 |
/** |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
73 |
* Constructor that allows the creation of an sqlite result with a custom |
1
by edam
- initial commit |
74 |
* message. |
22
by edam
updated email and web addresses |
75 |
* |
1
by edam
- initial commit |
76 |
* @param message a customer error message string |
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
77 |
* @param code the sqlite result code |
1
by edam
- initial commit |
78 |
*/ |
2
by edam
- further initial development |
79 |
explicit sqlite_error( |
1
by edam
- initial commit |
80 |
const std::string &message, |
9
by edam
- added NEWS |
81 |
int code = SQLITE_ERROR ); |
1
by edam
- initial commit |
82 |
|
83 |
virtual ~sqlite_error() throw( ); |
|
84 |
||
85 |
//______________________________________________________________________________ |
|
86 |
// public interface |
|
87 |
public: |
|
88 |
||
89 |
/** |
|
22
by edam
updated email and web addresses |
90 |
* Get the sqlite result code associated with this error. |
91 |
* |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
92 |
* @returns the sqlite result code |
1
by edam
- initial commit |
93 |
*/ |
9
by edam
- added NEWS |
94 |
int get_code() const; |
1
by edam
- initial commit |
95 |
|
96 |
/** |
|
97 |
* Get the error message |
|
98 |
* @returns the error message |
|
99 |
*/ |
|
100 |
virtual const char* what() const throw( ); |
|
101 |
||
102 |
//______________________________________________________________________________ |
|
103 |
// implementation |
|
104 |
private: |
|
105 |
||
106 |
/** |
|
22
by edam
updated email and web addresses |
107 |
* Retrieve an automatic error message for a given sqlite result code. |
108 |
* |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
109 |
* @param the sqlite result code |
1
by edam
- initial commit |
110 |
* @returns the automatic string |
111 |
*/ |
|
9
by edam
- added NEWS |
112 |
const std::string &get_message( |
113 |
int code ); |
|
1
by edam
- initial commit |
114 |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
115 |
/** the result code */ |
9
by edam
- added NEWS |
116 |
int _code; |
1
by edam
- initial commit |
117 |
|
118 |
/** the message string */ |
|
119 |
std::string _message; |
|
120 |
||
121 |
}; |
|
122 |
||
123 |
||
2
by edam
- further initial development |
124 |
} // namespace sqlite |
125 |
||
126 |
||
127 |
#endif /* SQLITE3CC_EXCEPTION_H_ */ |