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 |
* |
4 |
* Copyright (C) 2009 Tim Marston <edam@waxworlds.org> |
|
5 |
* |
|
2
by edam
- further initial development |
6 |
* This file is part of sqlite3cc (hereafter referred to as "this program"). |
7 |
* See http://www.waxworlds.org/edam/software/sqlite3cc for more information. |
|
1
by edam
- initial commit |
8 |
* |
9 |
* This program is free software: you can redistribute it and/or modify |
|
10 |
* it under the terms of the GNU Lesser General Public License as published |
|
11 |
* by the Free Software Foundation, either version 3 of the License, or |
|
12 |
* (at your option) any later version. |
|
13 |
* |
|
14 |
* This program is distributed in the hope that it will be useful, |
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
* GNU Lesser General Public License for more details. |
|
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 |
51 |
* to determine it's error message |
|
52 |
* @param connection a reference to a connection |
|
53 |
* @param code the sqlite result code |
|
13
by edam
- made basic_statement::step() protected, for use by query and command only |
54 |
* @see sqlite_errmsg() |
55 |
*/ |
|
56 |
explicit sqlite_error( |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
57 |
connection &connection, |
13
by edam
- made basic_statement::step() protected, for use by query and command only |
58 |
int code ); |
59 |
||
60 |
||
61 |
/** |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
62 |
* Constructor that takes an sqlite result code and determines it's own |
13
by edam
- made basic_statement::step() protected, for use by query and command only |
63 |
* generic error message |
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
64 |
* @param code the sqlite result code |
1
by edam
- initial commit |
65 |
*/ |
2
by edam
- further initial development |
66 |
explicit sqlite_error( |
9
by edam
- added NEWS |
67 |
int code ); |
1
by edam
- initial commit |
68 |
|
69 |
/** |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
70 |
* Constructor that allows the creation of an sqlite result with a custom |
1
by edam
- initial commit |
71 |
* message. |
72 |
* @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?) |
73 |
* @param code the sqlite result code |
1
by edam
- initial commit |
74 |
*/ |
2
by edam
- further initial development |
75 |
explicit sqlite_error( |
1
by edam
- initial commit |
76 |
const std::string &message, |
9
by edam
- added NEWS |
77 |
int code = SQLITE_ERROR ); |
1
by edam
- initial commit |
78 |
|
79 |
virtual ~sqlite_error() throw( ); |
|
80 |
||
81 |
//______________________________________________________________________________ |
|
82 |
// public interface |
|
83 |
public: |
|
84 |
||
85 |
/** |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
86 |
* Get the sqlite result code associated with this error |
87 |
* @returns the sqlite result code |
|
1
by edam
- initial commit |
88 |
*/ |
9
by edam
- added NEWS |
89 |
int get_code() const; |
1
by edam
- initial commit |
90 |
|
91 |
/** |
|
92 |
* Get the error message |
|
93 |
* @returns the error message |
|
94 |
*/ |
|
95 |
virtual const char* what() const throw( ); |
|
96 |
||
97 |
//______________________________________________________________________________ |
|
98 |
// implementation |
|
99 |
private: |
|
100 |
||
101 |
/** |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
102 |
* Retrieve an automatic error message for a given sqlite result code |
103 |
* @param the sqlite result code |
|
1
by edam
- initial commit |
104 |
* @returns the automatic string |
105 |
*/ |
|
9
by edam
- added NEWS |
106 |
const std::string &get_message( |
107 |
int code ); |
|
1
by edam
- initial commit |
108 |
|
16
by edam
- renamed database to connection to better identify what it is (would database_connection be better though?) |
109 |
/** the result code */ |
9
by edam
- added NEWS |
110 |
int _code; |
1
by edam
- initial commit |
111 |
|
112 |
/** the message string */ |
|
113 |
std::string _message; |
|
114 |
||
115 |
}; |
|
116 |
||
117 |
||
2
by edam
- further initial development |
118 |
} // namespace sqlite |
119 |
||
120 |
||
121 |
#endif /* SQLITE3CC_EXCEPTION_H_ */ |