summaryrefslogtreecommitdiffabout
path: root/include/opkele/exception.h
Unidiff
Diffstat (limited to 'include/opkele/exception.h') (more/less context) (show whitespace changes)
-rw-r--r--include/opkele/exception.h95
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
@@ -1,235 +1,316 @@
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
56namespace opkele { 64namespace 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) { }
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 */
82 }; 87 };
83 88
84 /** 89 /**
85 * thrown in case of failed conversion 90 * thrown in case of failed conversion
86 */ 91 */
87 class failed_conversion : public exception { 92 class failed_conversion : public exception {
88 public: 93 public:
89 failed_conversion(OPKELE_E_PARS) 94 failed_conversion(OPKELE_E_PARS)
90 : exception(OPKELE_E_CONS) { } 95 : exception(OPKELE_E_CONS) { }
91 }; 96 };
92 /** 97 /**
93 * thrown in case of failed lookup (either parameter or persistent store) 98 * thrown in case of failed lookup (either parameter or persistent store)
94 */ 99 */
95 class failed_lookup : public exception { 100 class failed_lookup : public exception {
96 public: 101 public:
97 failed_lookup(OPKELE_E_PARS) 102 failed_lookup(OPKELE_E_PARS)
98 : exception(OPKELE_E_CONS) { } 103 : exception(OPKELE_E_CONS) { }
99 }; 104 };
100 /** 105 /**
101 * thrown in case of bad input (either local or network) 106 * thrown in case of bad input (either local or network)
102 */ 107 */
103 class bad_input : public exception { 108 class bad_input : public exception {
104 public: 109 public:
105 bad_input(OPKELE_E_PARS) 110 bad_input(OPKELE_E_PARS)
106 : exception(OPKELE_E_CONS) { } 111 : exception(OPKELE_E_CONS) { }
107 }; 112 };
108 113
109 /** 114 /**
110 * thrown on failed assertion 115 * thrown on failed assertion
111 */ 116 */
112 class failed_assertion : public exception { 117 class failed_assertion : public exception {
113 public: 118 public:
114 failed_assertion(OPKELE_E_PARS) 119 failed_assertion(OPKELE_E_PARS)
115 : exception(OPKELE_E_CONS) { } 120 : exception(OPKELE_E_CONS) { }
116 }; 121 };
117 122
118 /** 123 /**
119 * thrown if the handle being retrieved is invalid 124 * thrown if the handle being retrieved is invalid
120 */ 125 */
121 class invalid_handle : public exception { 126 class invalid_handle : public exception {
122 public: 127 public:
123 invalid_handle(OPKELE_E_PARS) 128 invalid_handle(OPKELE_E_PARS)
124 : exception(OPKELE_E_CONS) { } 129 : exception(OPKELE_E_CONS) { }
125 }; 130 };
126 /** 131 /**
127 * thrown if the handle passed to check_authentication request is not 132 * thrown if the handle passed to check_authentication request is not
128 * stateless 133 * stateless
129 */ 134 */
130 class stateful_handle : public exception { 135 class stateful_handle : public exception {
131 public: 136 public:
132 stateful_handle(OPKELE_E_PARS) 137 stateful_handle(OPKELE_E_PARS)
133 : exception(OPKELE_E_CONS) { } 138 : exception(OPKELE_E_CONS) { }
134 }; 139 };
135 140
136 /** 141 /**
137 * thrown if check_authentication request fails 142 * thrown if check_authentication request fails
138 */ 143 */
139 class failed_check_authentication : public exception { 144 class failed_check_authentication : public exception {
140 public: 145 public:
141 failed_check_authentication(OPKELE_E_PARS) 146 failed_check_authentication(OPKELE_E_PARS)
142 : exception(OPKELE_E_CONS) { } 147 : exception(OPKELE_E_CONS) { }
143 }; 148 };
144 149
145 /** 150 /**
146 * thrown if the id_res request result is negative 151 * thrown if the id_res request result is negative
147 */ 152 */
148 class id_res_failed : public exception { 153 class id_res_failed : public exception {
149 public: 154 public:
150 id_res_failed(OPKELE_E_PARS) 155 id_res_failed(OPKELE_E_PARS)
151 : exception(OPKELE_E_CONS) { } 156 : exception(OPKELE_E_CONS) { }
152 }; 157 };
153 /** 158 /**
154 * thrown if the user_setup_url is provided with negative response 159 * thrown if the user_setup_url is provided with negative response
155 */ 160 */
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 };
163 /** 168 /**
164 * thrown in case of signature mismatch 169 * thrown in case of signature mismatch
165 */ 170 */
166 class id_res_mismatch : public id_res_failed { 171 class id_res_mismatch : public id_res_failed {
167 public: 172 public:
168 id_res_mismatch(OPKELE_E_PARS) 173 id_res_mismatch(OPKELE_E_PARS)
169 : id_res_failed(OPKELE_E_CONS) { } 174 : id_res_failed(OPKELE_E_CONS) { }
170 }; 175 };
171 176
172 /** 177 /**
173 * 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.
174 */ 179 */
175 class id_res_expired_on_delivery : public id_res_failed { 180 class id_res_expired_on_delivery : public id_res_failed {
176 public: 181 public:
177 id_res_expired_on_delivery(OPKELE_E_PARS) 182 id_res_expired_on_delivery(OPKELE_E_PARS)
178 : id_res_failed(OPKELE_E_CONS) { } 183 : id_res_failed(OPKELE_E_CONS) { }
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 {
185 public: 226 public:
186 unsigned long _error; 227 unsigned long _error;
187 string _ssl_string; 228 string _ssl_string;
188 exception_openssl(OPKELE_E_PARS); 229 exception_openssl(OPKELE_E_PARS);
189 ~exception_openssl() throw() { } 230 ~exception_openssl() throw() { }
190 }; 231 };
191 232
192 /** 233 /**
193 * network operation related error occured 234 * network operation related error occured
194 */ 235 */
195 class exception_network : public exception { 236 class exception_network : public exception {
196 public: 237 public:
197 exception_network(OPKELE_E_PARS) 238 exception_network(OPKELE_E_PARS)
198 : exception(OPKELE_E_CONS) { } 239 : exception(OPKELE_E_CONS) { }
199 }; 240 };
200 241
201 /** 242 /**
202 * network operation related error occured, specifically, related to 243 * network operation related error occured, specifically, related to
203 * libcurl 244 * libcurl
204 */ 245 */
205 class exception_curl : public exception_network { 246 class exception_curl : public exception_network {
206 public: 247 public:
207 CURLcode _error; 248 CURLcode _error;
208 string _curl_string; 249 string _curl_string;
209 exception_curl(OPKELE_E_PARS); 250 exception_curl(OPKELE_E_PARS);
210 exception_curl(OPKELE_E_PARS,CURLcode e); 251 exception_curl(OPKELE_E_PARS,CURLcode e);
211 ~exception_curl() throw() { } 252 ~exception_curl() throw() { }
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 */
218 class not_implemented : public exception { 289 class not_implemented : public exception {
219 public: 290 public:
220 not_implemented(OPKELE_E_PARS) 291 not_implemented(OPKELE_E_PARS)
221 : exception(OPKELE_E_CONS) { } 292 : exception(OPKELE_E_CONS) { }
222 }; 293 };
223 294
224 /** 295 /**
225 * internal error, indicates internal libopkele problem 296 * internal error, indicates internal libopkele problem
226 */ 297 */
227 class internal_error : public exception { 298 class internal_error : public exception {
228 public: 299 public:
229 internal_error(OPKELE_E_PARS) 300 internal_error(OPKELE_E_PARS)
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 */