author | Michael Krelin <hacker@klever.net> | 2007-01-11 00:57:06 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-01-11 00:57:06 (UTC) |
commit | 06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9 (patch) (unidiff) | |
tree | ef978c5d86188d2fc4c7e98a921804d7bfeb5557 /include/opkele/exception.h | |
parent | 100199abfdf7a353f9ba2aa9618e0711213290d3 (diff) | |
download | libopkele-06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9.zip libopkele-06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9.tar.gz libopkele-06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9.tar.bz2 |
introduced extension hooks framework
-rw-r--r-- | include/opkele/exception.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/opkele/exception.h b/include/opkele/exception.h index c5f5811..9fc9bd3 100644 --- a/include/opkele/exception.h +++ b/include/opkele/exception.h | |||
@@ -1,210 +1,220 @@ | |||
1 | #ifndef __OPKELE_EXCEPTION_H | 1 | #ifndef __OPKELE_EXCEPTION_H |
2 | #define __OPKELE_EXCEPTION_H | 2 | #define __OPKELE_EXCEPTION_H |
3 | 3 | ||
4 | /** | 4 | /** |
5 | * @file | 5 | * @file |
6 | * @brief opkele exceptions | 6 | * @brief opkele exceptions |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <curl/curl.h> | 9 | #include <curl/curl.h> |
10 | 10 | ||
11 | #include <opkele/opkele-config.h> | 11 | #include <opkele/opkele-config.h> |
12 | #ifdef OPKELE_HAVE_KONFORKA | 12 | #ifdef OPKELE_HAVE_KONFORKA |
13 | # include <konforka/exception.h> | 13 | # include <konforka/exception.h> |
14 | /** | 14 | /** |
15 | * the exception parameters declaration | 15 | * the exception parameters declaration |
16 | */ | 16 | */ |
17 | # define OPKELE_E_PARS const string& fi,const string&fu,int l,const string& w | 17 | # define OPKELE_E_PARS const string& fi,const string&fu,int l,const string& w |
18 | /** | 18 | /** |
19 | * the exception parameters list to pass to constructor | 19 | * the exception parameters list to pass to constructor |
20 | */ | 20 | */ |
21 | # define OPKELE_E_CONS_ fi,fu,l, | 21 | # define OPKELE_E_CONS_ fi,fu,l, |
22 | /** | 22 | /** |
23 | * the exception codepoint specification | 23 | * the exception codepoint specification |
24 | */ | 24 | */ |
25 | # define OPKELE_CP_ CODEPOINT, | 25 | # define OPKELE_CP_ CODEPOINT, |
26 | /** | 26 | /** |
27 | * the simple rethrow of konforka-based exception | 27 | * the simple rethrow of konforka-based exception |
28 | */ | 28 | */ |
29 | # define OPKELE_RETHROW catch(konforka::exception& e) { e.see(CODEPOINT); throw } | 29 | # define OPKELE_RETHROW catch(konforka::exception& e) { e.see(CODEPOINT); throw } |
30 | #else /* OPKELE_HAVE_KONFORKA */ | 30 | #else /* OPKELE_HAVE_KONFORKA */ |
31 | # include <exception> | 31 | # include <exception> |
32 | # include <string> | 32 | # include <string> |
33 | /** | 33 | /** |
34 | * the exception parameter declaration | 34 | * the exception parameter declaration |
35 | */ | 35 | */ |
36 | # define OPKELE_E_PARS const string& w | 36 | # define OPKELE_E_PARS const string& w |
37 | /** | 37 | /** |
38 | * the dummy prefix for exception parameters list to prepend in the absence of | 38 | * the dummy prefix for exception parameters list to prepend in the absence of |
39 | * konforka library | 39 | * konforka library |
40 | */ | 40 | */ |
41 | # define OPKELE_E_CONS_ | 41 | # define OPKELE_E_CONS_ |
42 | /** | 42 | /** |
43 | * the dummy placeholder for konforka exception codepoint specification | 43 | * the dummy placeholder for konforka exception codepoint specification |
44 | */ | 44 | */ |
45 | # define OPKELE_CP_ | 45 | # define OPKELE_CP_ |
46 | /** | 46 | /** |
47 | * the dummy define for the konforka-based rethrow of exception | 47 | * the dummy define for the konforka-based rethrow of exception |
48 | */ | 48 | */ |
49 | # define OPKELE_RETHROW | 49 | # define OPKELE_RETHROW |
50 | #endif /* OPKELE_HAVE_KONFORKA */ | 50 | #endif /* OPKELE_HAVE_KONFORKA */ |
51 | /** | 51 | /** |
52 | * the exception parameters list to pass to constructor | 52 | * the exception parameters list to pass to constructor |
53 | */ | 53 | */ |
54 | # define OPKELE_E_CONS OPKELE_E_CONS_ w | 54 | # define OPKELE_E_CONS OPKELE_E_CONS_ w |
55 | 55 | ||
56 | /* | 56 | /* |
57 | * @brief the main opkele namespace | 57 | * @brief the main opkele namespace |
58 | */ | 58 | */ |
59 | namespace opkele { | 59 | namespace opkele { |
60 | using std::string; | 60 | using std::string; |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * the base opkele exception class | 63 | * the base opkele exception class |
64 | */ | 64 | */ |
65 | class exception : public | 65 | class exception : public |
66 | # ifdef OPKELE_HAVE_KONFORKA | 66 | # ifdef OPKELE_HAVE_KONFORKA |
67 | konforka::exception | 67 | konforka::exception |
68 | # else | 68 | # else |
69 | std::exception | 69 | std::exception |
70 | # endif | 70 | # endif |
71 | { | 71 | { |
72 | public: | 72 | public: |
73 | # ifdef OPKELE_HAVE_KONFORKA | 73 | # ifdef OPKELE_HAVE_KONFORKA |
74 | explicit | 74 | explicit |
75 | exception(const string& fi,const string& fu,int l,const string& w) | 75 | exception(const string& fi,const string& fu,int l,const string& w) |
76 | : konforka::exception(fi,fu,l,w) { } | 76 | : konforka::exception(fi,fu,l,w) { } |
77 | # else /* OPKELE_HAVE_KONFORKA */ | 77 | # else /* OPKELE_HAVE_KONFORKA */ |
78 | string _what; | 78 | string _what; |
79 | explicit | 79 | explicit |
80 | exception(const string& w) | 80 | exception(const string& w) |
81 | : _what(w) { } | 81 | : _what(w) { } |
82 | virtual ~exception() throw(); | 82 | virtual ~exception() throw(); |
83 | virtual const char * what() const throw(); | 83 | virtual const char * what() const throw(); |
84 | # endif /* OPKELE_HAVE_KONFORKA */ | 84 | # endif /* OPKELE_HAVE_KONFORKA */ |
85 | }; | 85 | }; |
86 | 86 | ||
87 | /** | 87 | /** |
88 | * thrown in case of failed conversion | 88 | * thrown in case of failed conversion |
89 | */ | 89 | */ |
90 | class failed_conversion : public exception { | 90 | class failed_conversion : public exception { |
91 | public: | 91 | public: |
92 | failed_conversion(OPKELE_E_PARS) | 92 | failed_conversion(OPKELE_E_PARS) |
93 | : exception(OPKELE_E_CONS) { } | 93 | : exception(OPKELE_E_CONS) { } |
94 | }; | 94 | }; |
95 | /** | 95 | /** |
96 | * thrown in case of failed lookup (either parameter or persistent store) | 96 | * thrown in case of failed lookup (either parameter or persistent store) |
97 | */ | 97 | */ |
98 | class failed_lookup : public exception { | 98 | class failed_lookup : public exception { |
99 | public: | 99 | public: |
100 | failed_lookup(OPKELE_E_PARS) | 100 | failed_lookup(OPKELE_E_PARS) |
101 | : exception(OPKELE_E_CONS) { } | 101 | : exception(OPKELE_E_CONS) { } |
102 | }; | 102 | }; |
103 | /** | 103 | /** |
104 | * thrown in case of bad input (either local or network) | 104 | * thrown in case of bad input (either local or network) |
105 | */ | 105 | */ |
106 | class bad_input : public exception { | 106 | class bad_input : public exception { |
107 | public: | 107 | public: |
108 | bad_input(OPKELE_E_PARS) | 108 | bad_input(OPKELE_E_PARS) |
109 | : exception(OPKELE_E_CONS) { } | 109 | : exception(OPKELE_E_CONS) { } |
110 | }; | 110 | }; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | * thrown on failed assertion | 113 | * thrown on failed assertion |
114 | */ | 114 | */ |
115 | class failed_assertion : public exception { | 115 | class failed_assertion : public exception { |
116 | public: | 116 | public: |
117 | failed_assertion(OPKELE_E_PARS) | 117 | failed_assertion(OPKELE_E_PARS) |
118 | : exception(OPKELE_E_CONS) { } | 118 | : exception(OPKELE_E_CONS) { } |
119 | }; | 119 | }; |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * thrown if the handle being retrieved is invalid | 122 | * thrown if the handle being retrieved is invalid |
123 | */ | 123 | */ |
124 | class invalid_handle : public exception { | 124 | class invalid_handle : public exception { |
125 | public: | 125 | public: |
126 | invalid_handle(OPKELE_E_PARS) | 126 | invalid_handle(OPKELE_E_PARS) |
127 | : exception(OPKELE_E_CONS) { } | 127 | : exception(OPKELE_E_CONS) { } |
128 | }; | 128 | }; |
129 | /** | 129 | /** |
130 | * thrown if the handle passed to check_authentication request is not | 130 | * thrown if the handle passed to check_authentication request is not |
131 | * stateless | 131 | * stateless |
132 | */ | 132 | */ |
133 | class stateful_handle : public exception { | 133 | class stateful_handle : public exception { |
134 | public: | 134 | public: |
135 | stateful_handle(OPKELE_E_PARS) | 135 | stateful_handle(OPKELE_E_PARS) |
136 | : exception(OPKELE_E_CONS) { } | 136 | : exception(OPKELE_E_CONS) { } |
137 | }; | 137 | }; |
138 | 138 | ||
139 | /** | 139 | /** |
140 | * thrown if check_authentication request fails | 140 | * thrown if check_authentication request fails |
141 | */ | 141 | */ |
142 | class failed_check_authentication : public exception { | 142 | class failed_check_authentication : public exception { |
143 | public: | 143 | public: |
144 | failed_check_authentication(OPKELE_E_PARS) | 144 | failed_check_authentication(OPKELE_E_PARS) |
145 | : exception(OPKELE_E_CONS) { } | 145 | : exception(OPKELE_E_CONS) { } |
146 | }; | 146 | }; |
147 | 147 | ||
148 | /** | 148 | /** |
149 | * thrown if the id_res request result is negative | 149 | * thrown if the id_res request result is negative |
150 | */ | 150 | */ |
151 | class id_res_failed : public exception { | 151 | class id_res_failed : public exception { |
152 | public: | 152 | public: |
153 | id_res_failed(OPKELE_E_PARS) | 153 | id_res_failed(OPKELE_E_PARS) |
154 | : exception(OPKELE_E_CONS) { } | 154 | : exception(OPKELE_E_CONS) { } |
155 | }; | 155 | }; |
156 | /** | 156 | /** |
157 | * thrown if the user_setup_url is provided with negative response | 157 | * thrown if the user_setup_url is provided with negative response |
158 | */ | 158 | */ |
159 | class id_res_setup : public id_res_failed { | 159 | class id_res_setup : public id_res_failed { |
160 | public: | 160 | public: |
161 | string setup_url; | 161 | string setup_url; |
162 | id_res_setup(OPKELE_E_PARS,const string& su) | 162 | id_res_setup(OPKELE_E_PARS,const string& su) |
163 | : id_res_failed(OPKELE_E_CONS), setup_url(su) { } | 163 | : id_res_failed(OPKELE_E_CONS), setup_url(su) { } |
164 | ~id_res_setup() throw() { } | 164 | ~id_res_setup() throw() { } |
165 | }; | 165 | }; |
166 | /** | 166 | /** |
167 | * thrown in case of signature mismatch | 167 | * thrown in case of signature mismatch |
168 | */ | 168 | */ |
169 | class id_res_mismatch : public id_res_failed { | 169 | class id_res_mismatch : public id_res_failed { |
170 | public: | 170 | public: |
171 | id_res_mismatch(OPKELE_E_PARS) | 171 | id_res_mismatch(OPKELE_E_PARS) |
172 | : id_res_failed(OPKELE_E_CONS) { } | 172 | : id_res_failed(OPKELE_E_CONS) { } |
173 | }; | 173 | }; |
174 | 174 | ||
175 | /** | 175 | /** |
176 | * openssl malfunction occured | 176 | * openssl malfunction occured |
177 | */ | 177 | */ |
178 | class exception_openssl : public exception { | 178 | class exception_openssl : public exception { |
179 | public: | 179 | public: |
180 | unsigned long _error; | 180 | unsigned long _error; |
181 | string _ssl_string; | 181 | string _ssl_string; |
182 | exception_openssl(OPKELE_E_PARS); | 182 | exception_openssl(OPKELE_E_PARS); |
183 | ~exception_openssl() throw() { } | 183 | ~exception_openssl() throw() { } |
184 | }; | 184 | }; |
185 | 185 | ||
186 | /** | 186 | /** |
187 | * network operation related error occured | 187 | * network operation related error occured |
188 | */ | 188 | */ |
189 | class exception_network : public exception { | 189 | class exception_network : public exception { |
190 | public: | 190 | public: |
191 | exception_network(OPKELE_E_PARS) | 191 | exception_network(OPKELE_E_PARS) |
192 | : exception(OPKELE_E_CONS) { } | 192 | : exception(OPKELE_E_CONS) { } |
193 | }; | 193 | }; |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * network operation related error occured, specifically, related to | 196 | * network operation related error occured, specifically, related to |
197 | * libcurl | 197 | * libcurl |
198 | */ | 198 | */ |
199 | class exception_curl : public exception_network { | 199 | class exception_curl : public exception_network { |
200 | public: | 200 | public: |
201 | CURLcode _error; | 201 | CURLcode _error; |
202 | string _curl_string; | 202 | string _curl_string; |
203 | exception_curl(OPKELE_E_PARS); | 203 | exception_curl(OPKELE_E_PARS); |
204 | exception_curl(OPKELE_E_PARS,CURLcode e); | 204 | exception_curl(OPKELE_E_PARS,CURLcode e); |
205 | ~exception_curl() throw() { } | 205 | ~exception_curl() throw() { } |
206 | }; | 206 | }; |
207 | 207 | ||
208 | /** | ||
209 | * not implemented (think pure virtual) member function executed, signfies | ||
210 | * programmer error | ||
211 | */ | ||
212 | class not_implemented : public exception { | ||
213 | public: | ||
214 | not_implemented(OPKELE_E_PARS) | ||
215 | : exception(OPKELE_E_CONS) { } | ||
216 | }; | ||
217 | |||
208 | } | 218 | } |
209 | 219 | ||
210 | #endif /* __OPKELE_EXCEPTION_H */ | 220 | #endif /* __OPKELE_EXCEPTION_H */ |