author | Michael Krelin <hacker@klever.net> | 2007-12-30 21:55:36 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-01-04 18:23:09 (UTC) |
commit | 9e46475efea0f61bc588221d21d0d749c4eb7ab1 (patch) (unidiff) | |
tree | 472a840a9df3209ebcb1909dc40b0b08a50bbb3d /include/opkele/exception.h | |
parent | 40303fc819bc509f5593bf07c082f3d116023c18 (diff) | |
download | libopkele-9e46475efea0f61bc588221d21d0d749c4eb7ab1.zip libopkele-9e46475efea0f61bc588221d21d0d749c4eb7ab1.tar.gz libopkele-9e46475efea0f61bc588221d21d0d749c4eb7ab1.tar.bz2 |
exception fixes and enhancements
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | include/opkele/exception.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/include/opkele/exception.h b/include/opkele/exception.h index 8913665..36bd07a 100644 --- a/include/opkele/exception.h +++ b/include/opkele/exception.h | |||
@@ -1,254 +1,262 @@ | |||
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 | * open function-try-block | ||
28 | */ | ||
29 | # define OPKELE_FUNC_TRY try | ||
30 | /** | ||
27 | * the simple rethrow of konforka-based exception | 31 | * the simple rethrow of konforka-based exception |
28 | */ | 32 | */ |
29 | # define OPKELE_RETHROW catch(konforka::exception& e) { e.see(CODEPOINT); throw } | 33 | # define OPKELE_RETHROW catch(konforka::exception& e) { e.see(CODEPOINT); throw; } |
30 | #else /* OPKELE_HAVE_KONFORKA */ | 34 | #else /* OPKELE_HAVE_KONFORKA */ |
31 | # include <exception> | 35 | # include <exception> |
32 | # include <string> | 36 | # include <string> |
33 | /** | 37 | /** |
34 | * the exception parameter declaration | 38 | * the exception parameter declaration |
35 | */ | 39 | */ |
36 | # define OPKELE_E_PARS const string& w | 40 | # define OPKELE_E_PARS const string& w |
37 | /** | 41 | /** |
38 | * the dummy prefix for exception parameters list to prepend in the absence of | 42 | * the dummy prefix for exception parameters list to prepend in the absence of |
39 | * konforka library | 43 | * konforka library |
40 | */ | 44 | */ |
41 | # define OPKELE_E_CONS_ | 45 | # define OPKELE_E_CONS_ |
42 | /** | 46 | /** |
43 | * the dummy placeholder for konforka exception codepoint specification | 47 | * the dummy placeholder for konforka exception codepoint specification |
44 | */ | 48 | */ |
45 | # define OPKELE_CP_ | 49 | # define OPKELE_CP_ |
46 | /** | 50 | /** |
51 | * the dummy define for the opening function-try-block | ||
52 | */ | ||
53 | # define OPKELE_FUNC_TRY | ||
54 | /** | ||
47 | * the dummy define for the konforka-based rethrow of exception | 55 | * the dummy define for the konforka-based rethrow of exception |
48 | */ | 56 | */ |
49 | # define OPKELE_RETHROW | 57 | # define OPKELE_RETHROW |
50 | #endif /* OPKELE_HAVE_KONFORKA */ | 58 | #endif /* OPKELE_HAVE_KONFORKA */ |
51 | /** | 59 | /** |
52 | * the exception parameters list to pass to constructor | 60 | * the exception parameters list to pass to constructor |
53 | */ | 61 | */ |
54 | # define OPKELE_E_CONS OPKELE_E_CONS_ w | 62 | # define OPKELE_E_CONS OPKELE_E_CONS_ w |
55 | 63 | ||
56 | namespace opkele { | 64 | namespace opkele { |
57 | using std::string; | 65 | using std::string; |
58 | 66 | ||
59 | /** | 67 | /** |
60 | * the base opkele exception class | 68 | * the base opkele exception class |
61 | */ | 69 | */ |
62 | class exception : public | 70 | class exception : public |
63 | # ifdef OPKELE_HAVE_KONFORKA | 71 | # ifdef OPKELE_HAVE_KONFORKA |
64 | konforka::exception | 72 | konforka::exception |
65 | # else | 73 | # else |
66 | std::exception | 74 | std::exception |
67 | # endif | 75 | # endif |
68 | { | 76 | { |
69 | public: | 77 | public: |
70 | # ifdef OPKELE_HAVE_KONFORKA | 78 | # ifdef OPKELE_HAVE_KONFORKA |
71 | explicit | 79 | explicit |
72 | exception(const string& fi,const string& fu,int l,const string& w) | 80 | exception(const string& fi,const string& fu,int l,const string& w) |
73 | : konforka::exception(fi,fu,l,w) { } | 81 | : konforka::exception(fi,fu,l,w) { } |
74 | # else /* OPKELE_HAVE_KONFORKA */ | 82 | # else /* OPKELE_HAVE_KONFORKA */ |
75 | string _what; | 83 | string _what; |
76 | explicit | 84 | explicit |
77 | exception(const string& w) | 85 | exception(const string& w) |
78 | : _what(w) { } | 86 | : _what(w) { } |
79 | virtual ~exception() throw(); | 87 | virtual ~exception() throw(); |
80 | virtual const char * what() const throw(); | 88 | virtual const char * what() const throw(); |
81 | # endif /* OPKELE_HAVE_KONFORKA */ | 89 | # endif /* OPKELE_HAVE_KONFORKA */ |
82 | }; | 90 | }; |
83 | 91 | ||
84 | /** | 92 | /** |
85 | * thrown in case of failed conversion | 93 | * thrown in case of failed conversion |
86 | */ | 94 | */ |
87 | class failed_conversion : public exception { | 95 | class failed_conversion : public exception { |
88 | public: | 96 | public: |
89 | failed_conversion(OPKELE_E_PARS) | 97 | failed_conversion(OPKELE_E_PARS) |
90 | : exception(OPKELE_E_CONS) { } | 98 | : exception(OPKELE_E_CONS) { } |
91 | }; | 99 | }; |
92 | /** | 100 | /** |
93 | * thrown in case of failed lookup (either parameter or persistent store) | 101 | * thrown in case of failed lookup (either parameter or persistent store) |
94 | */ | 102 | */ |
95 | class failed_lookup : public exception { | 103 | class failed_lookup : public exception { |
96 | public: | 104 | public: |
97 | failed_lookup(OPKELE_E_PARS) | 105 | failed_lookup(OPKELE_E_PARS) |
98 | : exception(OPKELE_E_CONS) { } | 106 | : exception(OPKELE_E_CONS) { } |
99 | }; | 107 | }; |
100 | /** | 108 | /** |
101 | * thrown in case of bad input (either local or network) | 109 | * thrown in case of bad input (either local or network) |
102 | */ | 110 | */ |
103 | class bad_input : public exception { | 111 | class bad_input : public exception { |
104 | public: | 112 | public: |
105 | bad_input(OPKELE_E_PARS) | 113 | bad_input(OPKELE_E_PARS) |
106 | : exception(OPKELE_E_CONS) { } | 114 | : exception(OPKELE_E_CONS) { } |
107 | }; | 115 | }; |
108 | 116 | ||
109 | /** | 117 | /** |
110 | * thrown on failed assertion | 118 | * thrown on failed assertion |
111 | */ | 119 | */ |
112 | class failed_assertion : public exception { | 120 | class failed_assertion : public exception { |
113 | public: | 121 | public: |
114 | failed_assertion(OPKELE_E_PARS) | 122 | failed_assertion(OPKELE_E_PARS) |
115 | : exception(OPKELE_E_CONS) { } | 123 | : exception(OPKELE_E_CONS) { } |
116 | }; | 124 | }; |
117 | 125 | ||
118 | /** | 126 | /** |
119 | * thrown if the handle being retrieved is invalid | 127 | * thrown if the handle being retrieved is invalid |
120 | */ | 128 | */ |
121 | class invalid_handle : public exception { | 129 | class invalid_handle : public exception { |
122 | public: | 130 | public: |
123 | invalid_handle(OPKELE_E_PARS) | 131 | invalid_handle(OPKELE_E_PARS) |
124 | : exception(OPKELE_E_CONS) { } | 132 | : exception(OPKELE_E_CONS) { } |
125 | }; | 133 | }; |
126 | /** | 134 | /** |
127 | * thrown if the handle passed to check_authentication request is not | 135 | * thrown if the handle passed to check_authentication request is not |
128 | * stateless | 136 | * stateless |
129 | */ | 137 | */ |
130 | class stateful_handle : public exception { | 138 | class stateful_handle : public exception { |
131 | public: | 139 | public: |
132 | stateful_handle(OPKELE_E_PARS) | 140 | stateful_handle(OPKELE_E_PARS) |
133 | : exception(OPKELE_E_CONS) { } | 141 | : exception(OPKELE_E_CONS) { } |
134 | }; | 142 | }; |
135 | 143 | ||
136 | /** | 144 | /** |
137 | * thrown if check_authentication request fails | 145 | * thrown if check_authentication request fails |
138 | */ | 146 | */ |
139 | class failed_check_authentication : public exception { | 147 | class failed_check_authentication : public exception { |
140 | public: | 148 | public: |
141 | failed_check_authentication(OPKELE_E_PARS) | 149 | failed_check_authentication(OPKELE_E_PARS) |
142 | : exception(OPKELE_E_CONS) { } | 150 | : exception(OPKELE_E_CONS) { } |
143 | }; | 151 | }; |
144 | 152 | ||
145 | /** | 153 | /** |
146 | * thrown if the id_res request result is negative | 154 | * thrown if the id_res request result is negative |
147 | */ | 155 | */ |
148 | class id_res_failed : public exception { | 156 | class id_res_failed : public exception { |
149 | public: | 157 | public: |
150 | id_res_failed(OPKELE_E_PARS) | 158 | id_res_failed(OPKELE_E_PARS) |
151 | : exception(OPKELE_E_CONS) { } | 159 | : exception(OPKELE_E_CONS) { } |
152 | }; | 160 | }; |
153 | /** | 161 | /** |
154 | * thrown if the user_setup_url is provided with negative response | 162 | * thrown if the user_setup_url is provided with negative response |
155 | */ | 163 | */ |
156 | class id_res_setup : public id_res_failed { | 164 | class id_res_setup : public id_res_failed { |
157 | public: | 165 | public: |
158 | string setup_url; | 166 | string setup_url; |
159 | id_res_setup(OPKELE_E_PARS,const string& su) | 167 | id_res_setup(OPKELE_E_PARS,const string& su) |
160 | : id_res_failed(OPKELE_E_CONS), setup_url(su) { } | 168 | : id_res_failed(OPKELE_E_CONS), setup_url(su) { } |
161 | ~id_res_setup() throw() { } | 169 | ~id_res_setup() throw() { } |
162 | }; | 170 | }; |
163 | /** | 171 | /** |
164 | * thrown in case of signature mismatch | 172 | * thrown in case of signature mismatch |
165 | */ | 173 | */ |
166 | class id_res_mismatch : public id_res_failed { | 174 | class id_res_mismatch : public id_res_failed { |
167 | public: | 175 | public: |
168 | id_res_mismatch(OPKELE_E_PARS) | 176 | id_res_mismatch(OPKELE_E_PARS) |
169 | : id_res_failed(OPKELE_E_CONS) { } | 177 | : id_res_failed(OPKELE_E_CONS) { } |
170 | }; | 178 | }; |
171 | 179 | ||
172 | /** | 180 | /** |
173 | * thrown if the association has expired before it could've been verified. | 181 | * thrown if the association has expired before it could've been verified. |
174 | */ | 182 | */ |
175 | class id_res_expired_on_delivery : public id_res_failed { | 183 | class id_res_expired_on_delivery : public id_res_failed { |
176 | public: | 184 | public: |
177 | id_res_expired_on_delivery(OPKELE_E_PARS) | 185 | id_res_expired_on_delivery(OPKELE_E_PARS) |
178 | : id_res_failed(OPKELE_E_CONS) { } | 186 | : id_res_failed(OPKELE_E_CONS) { } |
179 | }; | 187 | }; |
180 | 188 | ||
181 | /** | 189 | /** |
182 | * openssl malfunction occured | 190 | * openssl malfunction occured |
183 | */ | 191 | */ |
184 | class exception_openssl : public exception { | 192 | class exception_openssl : public exception { |
185 | public: | 193 | public: |
186 | unsigned long _error; | 194 | unsigned long _error; |
187 | string _ssl_string; | 195 | string _ssl_string; |
188 | exception_openssl(OPKELE_E_PARS); | 196 | exception_openssl(OPKELE_E_PARS); |
189 | ~exception_openssl() throw() { } | 197 | ~exception_openssl() throw() { } |
190 | }; | 198 | }; |
191 | 199 | ||
192 | /** | 200 | /** |
193 | * network operation related error occured | 201 | * network operation related error occured |
194 | */ | 202 | */ |
195 | class exception_network : public exception { | 203 | class exception_network : public exception { |
196 | public: | 204 | public: |
197 | exception_network(OPKELE_E_PARS) | 205 | exception_network(OPKELE_E_PARS) |
198 | : exception(OPKELE_E_CONS) { } | 206 | : exception(OPKELE_E_CONS) { } |
199 | }; | 207 | }; |
200 | 208 | ||
201 | /** | 209 | /** |
202 | * network operation related error occured, specifically, related to | 210 | * network operation related error occured, specifically, related to |
203 | * libcurl | 211 | * libcurl |
204 | */ | 212 | */ |
205 | class exception_curl : public exception_network { | 213 | class exception_curl : public exception_network { |
206 | public: | 214 | public: |
207 | CURLcode _error; | 215 | CURLcode _error; |
208 | string _curl_string; | 216 | string _curl_string; |
209 | exception_curl(OPKELE_E_PARS); | 217 | exception_curl(OPKELE_E_PARS); |
210 | exception_curl(OPKELE_E_PARS,CURLcode e); | 218 | exception_curl(OPKELE_E_PARS,CURLcode e); |
211 | ~exception_curl() throw() { } | 219 | ~exception_curl() throw() { } |
212 | }; | 220 | }; |
213 | 221 | ||
214 | /** | 222 | /** |
215 | * exception thrown in case of failed discovery | 223 | * exception thrown in case of failed discovery |
216 | */ | 224 | */ |
217 | class failed_discovery : public exception { | 225 | class failed_discovery : public exception { |
218 | public: | 226 | public: |
219 | failed_discovery(OPKELE_E_PARS) | 227 | failed_discovery(OPKELE_E_PARS) |
220 | : exception(OPKELE_E_CONS) { } | 228 | : exception(OPKELE_E_CONS) { } |
221 | }; | 229 | }; |
222 | 230 | ||
223 | /** | 231 | /** |
224 | * unsuccessfull xri resolution | 232 | * unsuccessfull xri resolution |
225 | */ | 233 | */ |
226 | class failed_xri_resolution : public failed_discovery { | 234 | class failed_xri_resolution : public failed_discovery { |
227 | public: | 235 | public: |
228 | long _code; | 236 | long _code; |
229 | failed_xri_resolution(OPKELE_E_PARS,long _c=-1) | 237 | failed_xri_resolution(OPKELE_E_PARS,long _c=-1) |
230 | : failed_discovery(OPKELE_E_CONS), _code(_c) { } | 238 | : failed_discovery(OPKELE_E_CONS), _code(_c) { } |
231 | }; | 239 | }; |
232 | 240 | ||
233 | /** | 241 | /** |
234 | * not implemented (think pure virtual) member function executed, signfies | 242 | * not implemented (think pure virtual) member function executed, signfies |
235 | * programmer error | 243 | * programmer error |
236 | */ | 244 | */ |
237 | class not_implemented : public exception { | 245 | class not_implemented : public exception { |
238 | public: | 246 | public: |
239 | not_implemented(OPKELE_E_PARS) | 247 | not_implemented(OPKELE_E_PARS) |
240 | : exception(OPKELE_E_CONS) { } | 248 | : exception(OPKELE_E_CONS) { } |
241 | }; | 249 | }; |
242 | 250 | ||
243 | /** | 251 | /** |
244 | * internal error, indicates internal libopkele problem | 252 | * internal error, indicates internal libopkele problem |
245 | */ | 253 | */ |
246 | class internal_error : public exception { | 254 | class internal_error : public exception { |
247 | public: | 255 | public: |
248 | internal_error(OPKELE_E_PARS) | 256 | internal_error(OPKELE_E_PARS) |
249 | : exception(OPKELE_E_CONS) { } | 257 | : exception(OPKELE_E_CONS) { } |
250 | }; | 258 | }; |
251 | 259 | ||
252 | } | 260 | } |
253 | 261 | ||
254 | #endif /* __OPKELE_EXCEPTION_H */ | 262 | #endif /* __OPKELE_EXCEPTION_H */ |