-rw-r--r-- | include/opkele/exception.h | 95 |
1 files changed, 88 insertions, 7 deletions
diff --git a/include/opkele/exception.h b/include/opkele/exception.h index 2ff44b7..a8c3339 100644 --- a/include/opkele/exception.h +++ b/include/opkele/exception.h | |||
@@ -24,9 +24,13 @@ | |||
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> |
@@ -44,6 +48,10 @@ | |||
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 |
@@ -69,13 +77,10 @@ namespace opkele { | |||
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) { } | ||
74 | # else /* OPKELE_HAVE_KONFORKA */ | 81 | # else /* OPKELE_HAVE_KONFORKA */ |
75 | string _what; | 82 | string _what; |
76 | explicit | 83 | explicit exception(const string& w); |
77 | exception(const string& w) | ||
78 | : _what(w) { } | ||
79 | virtual ~exception() throw(); | 84 | virtual ~exception() throw(); |
80 | virtual const char * what() const throw(); | 85 | virtual const char * what() const throw(); |
81 | # endif /* OPKELE_HAVE_KONFORKA */ | 86 | # endif /* OPKELE_HAVE_KONFORKA */ |
@@ -156,7 +161,7 @@ namespace opkele { | |||
156 | class id_res_setup : public id_res_failed { | 161 | class id_res_setup : public id_res_failed { |
157 | public: | 162 | public: |
158 | string setup_url; | 163 | string setup_url; |
159 | id_res_setup(OPKELE_E_PARS,const string& su) | 164 | id_res_setup(OPKELE_E_PARS,const string& su="") |
160 | : id_res_failed(OPKELE_E_CONS), setup_url(su) { } | 165 | : id_res_failed(OPKELE_E_CONS), setup_url(su) { } |
161 | ~id_res_setup() throw() { } | 166 | ~id_res_setup() throw() { } |
162 | }; | 167 | }; |
@@ -179,6 +184,42 @@ namespace opkele { | |||
179 | }; | 184 | }; |
180 | 185 | ||
181 | /** | 186 | /** |
187 | * thown when the user cancelled authentication process. | ||
188 | */ | ||
189 | class id_res_cancel : public id_res_failed { | ||
190 | public: | ||
191 | id_res_cancel(OPKELE_E_PARS) | ||
192 | : id_res_failed(OPKELE_E_CONS) { } | ||
193 | }; | ||
194 | |||
195 | /** | ||
196 | * thrown in case of nonce reuse or otherwise imperfect nonce. | ||
197 | */ | ||
198 | class id_res_bad_nonce : public id_res_failed { | ||
199 | public: | ||
200 | id_res_bad_nonce(OPKELE_E_PARS) | ||
201 | : id_res_failed(OPKELE_E_CONS) { } | ||
202 | }; | ||
203 | |||
204 | /** | ||
205 | * thrown if return_to didn't pass verification | ||
206 | */ | ||
207 | class id_res_bad_return_to : public id_res_failed { | ||
208 | public: | ||
209 | id_res_bad_return_to(OPKELE_E_PARS) | ||
210 | : id_res_failed(OPKELE_E_CONS) { } | ||
211 | }; | ||
212 | |||
213 | /** | ||
214 | * thrown if OP isn't authorized to make an assertion | ||
215 | */ | ||
216 | class id_res_unauthorized : public id_res_failed { | ||
217 | public: | ||
218 | id_res_unauthorized(OPKELE_E_PARS) | ||
219 | : id_res_failed(OPKELE_E_CONS) { } | ||
220 | }; | ||
221 | |||
222 | /** | ||
182 | * openssl malfunction occured | 223 | * openssl malfunction occured |
183 | */ | 224 | */ |
184 | class exception_openssl : public exception { | 225 | class exception_openssl : public exception { |
@@ -212,6 +253,36 @@ namespace opkele { | |||
212 | }; | 253 | }; |
213 | 254 | ||
214 | /** | 255 | /** |
256 | * htmltidy related error occured | ||
257 | */ | ||
258 | class exception_tidy : public exception { | ||
259 | public: | ||
260 | int _rc; | ||
261 | exception_tidy(OPKELE_E_PARS); | ||
262 | exception_tidy(OPKELE_E_PARS,int r); | ||
263 | ~exception_tidy() throw() { } | ||
264 | }; | ||
265 | |||
266 | /** | ||
267 | * exception thrown in case of failed discovery | ||
268 | */ | ||
269 | class failed_discovery : public exception { | ||
270 | public: | ||
271 | failed_discovery(OPKELE_E_PARS) | ||
272 | : exception(OPKELE_E_CONS) { } | ||
273 | }; | ||
274 | |||
275 | /** | ||
276 | * unsuccessfull xri resolution | ||
277 | */ | ||
278 | class failed_xri_resolution : public failed_discovery { | ||
279 | public: | ||
280 | long _code; | ||
281 | failed_xri_resolution(OPKELE_E_PARS,long _c=-1) | ||
282 | : failed_discovery(OPKELE_E_CONS), _code(_c) { } | ||
283 | }; | ||
284 | |||
285 | /** | ||
215 | * not implemented (think pure virtual) member function executed, signfies | 286 | * not implemented (think pure virtual) member function executed, signfies |
216 | * programmer error | 287 | * programmer error |
217 | */ | 288 | */ |
@@ -230,6 +301,16 @@ namespace opkele { | |||
230 | : exception(OPKELE_E_CONS) { } | 301 | : exception(OPKELE_E_CONS) { } |
231 | }; | 302 | }; |
232 | 303 | ||
304 | /** | ||
305 | * thrown in case of unsupported parameter encountered (e.g. unsupported | ||
306 | * association type). | ||
307 | */ | ||
308 | class unsupported : public exception { | ||
309 | public: | ||
310 | unsupported(OPKELE_E_PARS) | ||
311 | : exception(OPKELE_E_CONS) { } | ||
312 | }; | ||
313 | |||
233 | } | 314 | } |
234 | 315 | ||
235 | #endif /* __OPKELE_EXCEPTION_H */ | 316 | #endif /* __OPKELE_EXCEPTION_H */ |