summaryrefslogtreecommitdiffabout
path: root/include/opkele/exception.h
authorMichael Krelin <hacker@klever.net>2008-01-20 21:08:05 (UTC)
committer Michael Krelin <hacker@klever.net>2008-01-20 21:08:05 (UTC)
commit9bfb6fadf71c46bf4cb5adabba0c96c32e84c1bc (patch) (unidiff)
tree702473142242e80538c4801cc379ec98fba199dd /include/opkele/exception.h
parent395a126cbf59b7a50f44da3096b68bab412ab33d (diff)
downloadlibopkele-9bfb6fadf71c46bf4cb5adabba0c96c32e84c1bc.zip
libopkele-9bfb6fadf71c46bf4cb5adabba0c96c32e84c1bc.tar.gz
libopkele-9bfb6fadf71c46bf4cb5adabba0c96c32e84c1bc.tar.bz2
the whole library rewritten
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'include/opkele/exception.h') (more/less context) (ignore whitespace changes)
-rw-r--r--include/opkele/exception.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/opkele/exception.h b/include/opkele/exception.h
index a8c3339..ccb39d9 100644
--- a/include/opkele/exception.h
+++ b/include/opkele/exception.h
@@ -1,316 +1,335 @@
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 27 * open function-try-block
28 */ 28 */
29# define OPKELE_FUNC_TRY try 29# define OPKELE_FUNC_TRY try
30/** 30/**
31 * the simple rethrow of konforka-based exception 31 * the simple rethrow of konforka-based exception
32 */ 32 */
33# define OPKELE_RETHROW catch(konforka::exception& e) { e.see(CODEPOINT); throw; } 33# define OPKELE_RETHROW catch(konforka::exception& e) { e.see(CODEPOINT); throw; }
34#else /* OPKELE_HAVE_KONFORKA */ 34#else /* OPKELE_HAVE_KONFORKA */
35# include <exception> 35# include <exception>
36# include <string> 36# include <string>
37/** 37/**
38 * the exception parameter declaration 38 * the exception parameter declaration
39 */ 39 */
40# define OPKELE_E_PARS const string& w 40# define OPKELE_E_PARS const string& w
41/** 41/**
42 * 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
43 * konforka library 43 * konforka library
44 */ 44 */
45# define OPKELE_E_CONS_ 45# define OPKELE_E_CONS_
46/** 46/**
47 * the dummy placeholder for konforka exception codepoint specification 47 * the dummy placeholder for konforka exception codepoint specification
48 */ 48 */
49# define OPKELE_CP_ 49# define OPKELE_CP_
50/** 50/**
51 * the dummy define for the opening function-try-block 51 * the dummy define for the opening function-try-block
52 */ 52 */
53# define OPKELE_FUNC_TRY 53# define OPKELE_FUNC_TRY
54/** 54/**
55 * the dummy define for the konforka-based rethrow of exception 55 * the dummy define for the konforka-based rethrow of exception
56 */ 56 */
57# define OPKELE_RETHROW 57# define OPKELE_RETHROW
58#endif /* OPKELE_HAVE_KONFORKA */ 58#endif /* OPKELE_HAVE_KONFORKA */
59/** 59/**
60 * the exception parameters list to pass to constructor 60 * the exception parameters list to pass to constructor
61 */ 61 */
62# define OPKELE_E_CONS OPKELE_E_CONS_ w 62# define OPKELE_E_CONS OPKELE_E_CONS_ w
63 63
64namespace opkele { 64namespace opkele {
65 using std::string; 65 using std::string;
66 66
67 /** 67 /**
68 * the base opkele exception class 68 * the base opkele exception class
69 */ 69 */
70 class exception : public 70 class exception : public
71# ifdef OPKELE_HAVE_KONFORKA 71# ifdef OPKELE_HAVE_KONFORKA
72 konforka::exception 72 konforka::exception
73# else 73# else
74 std::exception 74 std::exception
75# endif 75# endif
76 { 76 {
77 public: 77 public:
78# ifdef OPKELE_HAVE_KONFORKA 78# ifdef OPKELE_HAVE_KONFORKA
79 explicit 79 explicit
80 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);
81# else /* OPKELE_HAVE_KONFORKA */ 81# else /* OPKELE_HAVE_KONFORKA */
82 string _what; 82 string _what;
83 explicit exception(const string& w); 83 explicit exception(const string& w);
84 virtual ~exception() throw(); 84 virtual ~exception() throw();
85 virtual const char * what() const throw(); 85 virtual const char * what() const throw();
86# endif /* OPKELE_HAVE_KONFORKA */ 86# endif /* OPKELE_HAVE_KONFORKA */
87 }; 87 };
88 88
89 /** 89 /**
90 * thrown in case of failed conversion 90 * thrown in case of failed conversion
91 */ 91 */
92 class failed_conversion : public exception { 92 class failed_conversion : public exception {
93 public: 93 public:
94 failed_conversion(OPKELE_E_PARS) 94 failed_conversion(OPKELE_E_PARS)
95 : exception(OPKELE_E_CONS) { } 95 : exception(OPKELE_E_CONS) { }
96 }; 96 };
97 /** 97 /**
98 * thrown in case of failed lookup (either parameter or persistent store) 98 * thrown in case of failed lookup (either parameter or persistent store)
99 */ 99 */
100 class failed_lookup : public exception { 100 class failed_lookup : public exception {
101 public: 101 public:
102 failed_lookup(OPKELE_E_PARS) 102 failed_lookup(OPKELE_E_PARS)
103 : exception(OPKELE_E_CONS) { } 103 : exception(OPKELE_E_CONS) { }
104 }; 104 };
105 /** 105 /**
106 * thrown in case of bad input (either local or network) 106 * thrown in case of bad input (either local or network)
107 */ 107 */
108 class bad_input : public exception { 108 class bad_input : public exception {
109 public: 109 public:
110 bad_input(OPKELE_E_PARS) 110 bad_input(OPKELE_E_PARS)
111 : exception(OPKELE_E_CONS) { } 111 : exception(OPKELE_E_CONS) { }
112 }; 112 };
113 113
114 /** 114 /**
115 * thrown on failed assertion 115 * thrown on failed assertion
116 */ 116 */
117 class failed_assertion : public exception { 117 class failed_assertion : public exception {
118 public: 118 public:
119 failed_assertion(OPKELE_E_PARS) 119 failed_assertion(OPKELE_E_PARS)
120 : exception(OPKELE_E_CONS) { } 120 : exception(OPKELE_E_CONS) { }
121 }; 121 };
122 122
123 /** 123 /**
124 * thrown if the handle being retrieved is invalid 124 * thrown if the handle being retrieved is invalid
125 */ 125 */
126 class invalid_handle : public exception { 126 class invalid_handle : public exception {
127 public: 127 public:
128 invalid_handle(OPKELE_E_PARS) 128 invalid_handle(OPKELE_E_PARS)
129 : exception(OPKELE_E_CONS) { } 129 : exception(OPKELE_E_CONS) { }
130 }; 130 };
131 /** 131 /**
132 * thrown if the handle passed to check_authentication request is not 132 * thrown if the handle passed to check_authentication request is not
133 * stateless 133 * stateless
134 */ 134 */
135 class stateful_handle : public exception { 135 class stateful_handle : public exception {
136 public: 136 public:
137 stateful_handle(OPKELE_E_PARS) 137 stateful_handle(OPKELE_E_PARS)
138 : exception(OPKELE_E_CONS) { } 138 : exception(OPKELE_E_CONS) { }
139 }; 139 };
140 140
141 /** 141 /**
142 * thrown if check_authentication request fails 142 * thrown if check_authentication request fails
143 */ 143 */
144 class failed_check_authentication : public exception { 144 class failed_check_authentication : public exception {
145 public: 145 public:
146 failed_check_authentication(OPKELE_E_PARS) 146 failed_check_authentication(OPKELE_E_PARS)
147 : exception(OPKELE_E_CONS) { } 147 : exception(OPKELE_E_CONS) { }
148 }; 148 };
149 149
150 /** 150 /**
151 * thrown if the id_res request result is negative 151 * thrown if the id_res request result is negative
152 */ 152 */
153 class id_res_failed : public exception { 153 class id_res_failed : public exception {
154 public: 154 public:
155 id_res_failed(OPKELE_E_PARS) 155 id_res_failed(OPKELE_E_PARS)
156 : exception(OPKELE_E_CONS) { } 156 : exception(OPKELE_E_CONS) { }
157 }; 157 };
158 /** 158 /**
159 * thrown if the user_setup_url is provided with negative response 159 * thrown if the user_setup_url is provided with negative response
160 */ 160 */
161 class id_res_setup : public id_res_failed { 161 class id_res_setup : public id_res_failed {
162 public: 162 public:
163 string setup_url; 163 string setup_url;
164 id_res_setup(OPKELE_E_PARS,const string& su="") 164 id_res_setup(OPKELE_E_PARS,const string& su="")
165 : id_res_failed(OPKELE_E_CONS), setup_url(su) { } 165 : id_res_failed(OPKELE_E_CONS), setup_url(su) { }
166 ~id_res_setup() throw() { } 166 ~id_res_setup() throw() { }
167 }; 167 };
168 /** 168 /**
169 * thrown in case of signature mismatch 169 * thrown in case of signature mismatch
170 */ 170 */
171 class id_res_mismatch : public id_res_failed { 171 class id_res_mismatch : public id_res_failed {
172 public: 172 public:
173 id_res_mismatch(OPKELE_E_PARS) 173 id_res_mismatch(OPKELE_E_PARS)
174 : id_res_failed(OPKELE_E_CONS) { } 174 : id_res_failed(OPKELE_E_CONS) { }
175 }; 175 };
176 176
177 /** 177 /**
178 * thrown if the association has expired before it could've been verified. 178 * thrown if the association has expired before it could've been verified.
179 */ 179 */
180 class id_res_expired_on_delivery : public id_res_failed { 180 class id_res_expired_on_delivery : public id_res_failed {
181 public: 181 public:
182 id_res_expired_on_delivery(OPKELE_E_PARS) 182 id_res_expired_on_delivery(OPKELE_E_PARS)
183 : id_res_failed(OPKELE_E_CONS) { } 183 : id_res_failed(OPKELE_E_CONS) { }
184 }; 184 };
185 185
186 /** 186 /**
187 * thown when the user cancelled authentication process. 187 * thown when the user cancelled authentication process.
188 */ 188 */
189 class id_res_cancel : public id_res_failed { 189 class id_res_cancel : public id_res_failed {
190 public: 190 public:
191 id_res_cancel(OPKELE_E_PARS) 191 id_res_cancel(OPKELE_E_PARS)
192 : id_res_failed(OPKELE_E_CONS) { } 192 : id_res_failed(OPKELE_E_CONS) { }
193 }; 193 };
194 194
195 /** 195 /**
196 * thrown in case of nonce reuse or otherwise imperfect nonce. 196 * thrown in case of nonce reuse or otherwise imperfect nonce.
197 */ 197 */
198 class id_res_bad_nonce : public id_res_failed { 198 class id_res_bad_nonce : public id_res_failed {
199 public: 199 public:
200 id_res_bad_nonce(OPKELE_E_PARS) 200 id_res_bad_nonce(OPKELE_E_PARS)
201 : id_res_failed(OPKELE_E_CONS) { } 201 : id_res_failed(OPKELE_E_CONS) { }
202 }; 202 };
203 203
204 /** 204 /**
205 * thrown if return_to didn't pass verification 205 * thrown if return_to didn't pass verification
206 */ 206 */
207 class id_res_bad_return_to : public id_res_failed { 207 class id_res_bad_return_to : public id_res_failed {
208 public: 208 public:
209 id_res_bad_return_to(OPKELE_E_PARS) 209 id_res_bad_return_to(OPKELE_E_PARS)
210 : id_res_failed(OPKELE_E_CONS) { } 210 : id_res_failed(OPKELE_E_CONS) { }
211 }; 211 };
212 212
213 /** 213 /**
214 * thrown if OP isn't authorized to make an assertion 214 * thrown if OP isn't authorized to make an assertion
215 */ 215 */
216 class id_res_unauthorized : public id_res_failed { 216 class id_res_unauthorized : public id_res_failed {
217 public: 217 public:
218 id_res_unauthorized(OPKELE_E_PARS) 218 id_res_unauthorized(OPKELE_E_PARS)
219 : id_res_failed(OPKELE_E_CONS) { } 219 : id_res_failed(OPKELE_E_CONS) { }
220 }; 220 };
221 221
222 /** 222 /**
223 * openssl malfunction occured 223 * openssl malfunction occured
224 */ 224 */
225 class exception_openssl : public exception { 225 class exception_openssl : public exception {
226 public: 226 public:
227 unsigned long _error; 227 unsigned long _error;
228 string _ssl_string; 228 string _ssl_string;
229 exception_openssl(OPKELE_E_PARS); 229 exception_openssl(OPKELE_E_PARS);
230 ~exception_openssl() throw() { } 230 ~exception_openssl() throw() { }
231 }; 231 };
232 232
233 /** 233 /**
234 * network operation related error occured 234 * network operation related error occured
235 */ 235 */
236 class exception_network : public exception { 236 class exception_network : public exception {
237 public: 237 public:
238 exception_network(OPKELE_E_PARS) 238 exception_network(OPKELE_E_PARS)
239 : exception(OPKELE_E_CONS) { } 239 : exception(OPKELE_E_CONS) { }
240 }; 240 };
241 241
242 /** 242 /**
243 * network operation related error occured, specifically, related to 243 * network operation related error occured, specifically, related to
244 * libcurl 244 * libcurl
245 */ 245 */
246 class exception_curl : public exception_network { 246 class exception_curl : public exception_network {
247 public: 247 public:
248 CURLcode _error; 248 CURLcode _error;
249 string _curl_string; 249 string _curl_string;
250 exception_curl(OPKELE_E_PARS); 250 exception_curl(OPKELE_E_PARS);
251 exception_curl(OPKELE_E_PARS,CURLcode e); 251 exception_curl(OPKELE_E_PARS,CURLcode e);
252 ~exception_curl() throw() { } 252 ~exception_curl() throw() { }
253 }; 253 };
254 254
255 /** 255 /**
256 * htmltidy related error occured 256 * htmltidy related error occured
257 */ 257 */
258 class exception_tidy : public exception { 258 class exception_tidy : public exception {
259 public: 259 public:
260 int _rc; 260 int _rc;
261 exception_tidy(OPKELE_E_PARS); 261 exception_tidy(OPKELE_E_PARS);
262 exception_tidy(OPKELE_E_PARS,int r); 262 exception_tidy(OPKELE_E_PARS,int r);
263 ~exception_tidy() throw() { } 263 ~exception_tidy() throw() { }
264 }; 264 };
265 265
266 /** 266 /**
267 * exception thrown in case of failed discovery 267 * exception thrown in case of failed discovery
268 */ 268 */
269 class failed_discovery : public exception { 269 class failed_discovery : public exception {
270 public: 270 public:
271 failed_discovery(OPKELE_E_PARS) 271 failed_discovery(OPKELE_E_PARS)
272 : exception(OPKELE_E_CONS) { } 272 : exception(OPKELE_E_CONS) { }
273 }; 273 };
274 274
275 /** 275 /**
276 * unsuccessfull xri resolution 276 * unsuccessfull xri resolution
277 */ 277 */
278 class failed_xri_resolution : public failed_discovery { 278 class failed_xri_resolution : public failed_discovery {
279 public: 279 public:
280 long _code; 280 long _code;
281 failed_xri_resolution(OPKELE_E_PARS,long _c=-1) 281 failed_xri_resolution(OPKELE_E_PARS,long _c=-1)
282 : failed_discovery(OPKELE_E_CONS), _code(_c) { } 282 : failed_discovery(OPKELE_E_CONS), _code(_c) { }
283 }; 283 };
284 284
285 /** 285 /**
286 * not implemented (think pure virtual) member function executed, signfies 286 * not implemented (think pure virtual) member function executed, signfies
287 * programmer error 287 * programmer error
288 */ 288 */
289 class not_implemented : public exception { 289 class not_implemented : public exception {
290 public: 290 public:
291 not_implemented(OPKELE_E_PARS) 291 not_implemented(OPKELE_E_PARS)
292 : exception(OPKELE_E_CONS) { } 292 : exception(OPKELE_E_CONS) { }
293 }; 293 };
294 294
295 /** 295 /**
296 * internal error, indicates internal libopkele problem 296 * internal error, indicates internal libopkele problem
297 */ 297 */
298 class internal_error : public exception { 298 class internal_error : public exception {
299 public: 299 public:
300 internal_error(OPKELE_E_PARS) 300 internal_error(OPKELE_E_PARS)
301 : exception(OPKELE_E_CONS) { } 301 : exception(OPKELE_E_CONS) { }
302 }; 302 };
303 303
304 /** 304 /**
305 * thrown in case of unsupported parameter encountered (e.g. unsupported 305 * thrown in case of unsupported parameter encountered (e.g. unsupported
306 * association type). 306 * association type).
307 */ 307 */
308 class unsupported : public exception { 308 class unsupported : public exception {
309 public: 309 public:
310 unsupported(OPKELE_E_PARS) 310 unsupported(OPKELE_E_PARS)
311 : exception(OPKELE_E_CONS) { } 311 : exception(OPKELE_E_CONS) { }
312 }; 312 };
313 313
314 /**
315 * thrown by associations store related functions in case of dumb RP.
316 */
317 class dumb_RP : public exception {
318 public:
319 dumb_RP(OPKELE_E_PARS)
320 : exception(OPKELE_E_CONS) { }
321 };
322
323 /**
324 * thrown by endpoint-queue related function if endpoint is being
325 * accessed but there's no endpoint available.
326 */
327 class no_endpoint : public exception {
328 public:
329 no_endpoint(OPKELE_E_PARS)
330 : exception(OPKELE_E_CONS) { }
331 };
332
314} 333}
315 334
316#endif /* __OPKELE_EXCEPTION_H */ 335#endif /* __OPKELE_EXCEPTION_H */