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> |
|
29 |
||
30 |
||
31 |
namespace sqlite |
|
32 |
{ |
|
33 |
||
34 |
||
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
35 |
class connection; |
13
by edam
- made basic_statement::step() protected, for use by query and command only |
36 |
|
37 |
||
1
by edam
- initial commit |
38 |
/** |
39 |
* Main (base) sqlite exception class. |
|
40 |
*/ |
|
41 |
class sqlite_error |
|
42 |
: |
|
43 |
public std::exception |
|
44 |
{ |
|
45 |
//______________________________________________________________________________ |
|
46 |
// instantiation |
|
47 |
public: |
|
48 |
||
49 |
/** |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
50 |
* Constructor that takes an sqlite result code and a connection from which |
22
by edam
updated email and web addresses |
51 |
* to determine it's error message. |
52 |
* |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
53 |
* @param connection a reference to a connection |
54 |
* @param code the sqlite result code |
|
13
by edam
- made basic_statement::step() protected, for use by query and command only |
55 |
* @see sqlite_errmsg() |
56 |
*/ |
|
57 |
explicit sqlite_error( |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
58 |
connection &connection, |
13
by edam
- made basic_statement::step() protected, for use by query and command only |
59 |
int code ); |
60 |
||
61 |
||
62 |
/** |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
63 |
* Constructor that takes an sqlite result code and determines it's own |
22
by edam
updated email and web addresses |
64 |
* generic error message. |
65 |
* |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
66 |
* @param code the sqlite result code |
1
by edam
- initial commit |
67 |
*/ |
2
by edam
- further initial development |
68 |
explicit sqlite_error( |
9
by edam
- added NEWS |
69 |
int code ); |
1
by edam
- initial commit |
70 |
|
71 |
/** |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
72 |
* Constructor that allows the creation of an sqlite result with a custom |
1
by edam
- initial commit |
73 |
* message. |
22
by edam
updated email and web addresses |
74 |
* |
1
by edam
- initial commit |
75 |
* @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?) |
76 |
* @param code the sqlite result code |
1
by edam
- initial commit |
77 |
*/ |
2
by edam
- further initial development |
78 |
explicit sqlite_error( |
1
by edam
- initial commit |
79 |
const std::string &message, |
9
by edam
- added NEWS |
80 |
int code = SQLITE_ERROR ); |
1
by edam
- initial commit |
81 |
|
82 |
virtual ~sqlite_error() throw( ); |
|
83 |
||
84 |
//______________________________________________________________________________ |
|
85 |
// public interface |
|
86 |
public: |
|
87 |
||
88 |
/** |
|
22
by edam
updated email and web addresses |
89 |
* Get the sqlite result code associated with this error. |
90 |
* |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
91 |
* @returns the sqlite result code |
1
by edam
- initial commit |
92 |
*/ |
9
by edam
- added NEWS |
93 |
int get_code() const; |
1
by edam
- initial commit |
94 |
|
95 |
/** |
|
96 |
* Get the error message |
|
97 |
* @returns the error message |
|
98 |
*/ |
|
99 |
virtual const char* what() const throw( ); |
|
100 |
||
101 |
//______________________________________________________________________________ |
|
102 |
// implementation |
|
103 |
private: |
|
104 |
||
105 |
/** |
|
22
by edam
updated email and web addresses |
106 |
* Retrieve an automatic error message for a given sqlite result code. |
107 |
* |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
108 |
* @param the sqlite result code |
1
by edam
- initial commit |
109 |
* @returns the automatic string |
110 |
*/ |
|
9
by edam
- added NEWS |
111 |
const std::string &get_message( |
112 |
int code ); |
|
1
by edam
- initial commit |
113 |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
114 |
/** the result code */ |
9
by edam
- added NEWS |
115 |
int _code; |
1
by edam
- initial commit |
116 |
|
117 |
/** the message string */ |
|
118 |
std::string _message; |
|
119 |
||
120 |
}; |
|
121 |
||
122 |
||
2
by edam
- further initial development |
123 |
} // namespace sqlite |
124 |
||
125 |
||
126 |
#endif /* SQLITE3CC_EXCEPTION_H_ */ |