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 | |
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,142 +1,150 @@ | |||
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) { } |