author | Michael Krelin <hacker@klever.net> | 2006-12-12 12:59:26 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2006-12-12 12:59:26 (UTC) |
commit | 4c22006b8012bafccf955c0d077971e67107ac35 (patch) (unidiff) | |
tree | 0a2c5748204a701576b8951e7658066e8e1c9c2b | |
parent | 08868f34ee339540ca392bb19e9c537d6e769464 (diff) | |
download | konforka-4c22006b8012bafccf955c0d077971e67107ac35.zip konforka-4c22006b8012bafccf955c0d077971e67107ac35.tar.gz konforka-4c22006b8012bafccf955c0d077971e67107ac35.tar.bz2 |
a few exception-handling convenience definitions
-rw-r--r-- | include/konforka/exception.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/konforka/exception.h b/include/konforka/exception.h index 5e0bf96..dbfe27c 100644 --- a/include/konforka/exception.h +++ b/include/konforka/exception.h | |||
@@ -5,48 +5,79 @@ | |||
5 | #include <string> | 5 | #include <string> |
6 | #include <list> | 6 | #include <list> |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * @file | 9 | * @file |
10 | * @brief exception-related stuff. | 10 | * @brief exception-related stuff. |
11 | * | 11 | * |
12 | * Basic exception-related declarations and definitions. | 12 | * Basic exception-related declarations and definitions. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | /** | 15 | /** |
16 | * @def CODEPOINT | 16 | * @def CODEPOINT |
17 | * the convenience definition of the parameters passed to the | 17 | * the convenience definition of the parameters passed to the |
18 | * konforka::code_point constructor. | 18 | * konforka::code_point constructor. |
19 | */ | 19 | */ |
20 | #defineCODEPOINT __FILE__,__PRETTY_FUNCTION__,__LINE__ | 20 | #defineCODEPOINT __FILE__,__PRETTY_FUNCTION__,__LINE__ |
21 | /** | 21 | /** |
22 | * @def NOCODEPOINT | 22 | * @def NOCODEPOINT |
23 | * the convenience definition for the codepoint denoting no particular point in | 23 | * the convenience definition for the codepoint denoting no particular point in |
24 | * code. | 24 | * code. |
25 | */ | 25 | */ |
26 | #define NOCODEPOINT "no information" | 26 | #define NOCODEPOINT "no information" |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * @def KONFORKA_RETHROW | ||
30 | * the convenience definition for seeing the exception and rethrowing it further. | ||
31 | */ | ||
32 | #define KONFORKA_RETHROW catch(konforka::exception& e) { e.see(CODEPOINT); throw; } | ||
33 | |||
34 | /** | ||
35 | * @def KONFORKA_E_ARGS | ||
36 | * the convenience definition for naming codepoint parameters | ||
37 | */ | ||
38 | #define KONFORKA_E_PARS const string& fi,const string& fu,int l,const string& w | ||
39 | |||
40 | /** | ||
41 | * @def KONFORKA_E_CONS | ||
42 | * the convenience definition for passing parameters to constructor | ||
43 | */ | ||
44 | #define KONFORKA_E_CONS fi,fu,l,w | ||
45 | |||
46 | /** | ||
47 | * @def KONFORKA_E_SUBCLASS | ||
48 | * the convenience definition for subclassing konforka exceptions | ||
49 | * @param base base class | ||
50 | * @param derived derived class | ||
51 | */ | ||
52 | #define KONFORKA_E_SUBCLASS(derived,base) \ | ||
53 | class derived : public base { \ | ||
54 | public: \ | ||
55 | explicit derived(KONFORKA_E_PARS) \ | ||
56 | : base(KONFORKA_E_CONS) { } \ | ||
57 | } | ||
58 | |||
59 | /** | ||
29 | * @brief The main konforka namespace. | 60 | * @brief The main konforka namespace. |
30 | */ | 61 | */ |
31 | namespace konforka { | 62 | namespace konforka { |
32 | using std::string; | 63 | using std::string; |
33 | using std::list; | 64 | using std::list; |
34 | 65 | ||
35 | /** | 66 | /** |
36 | * @brief Pinpoint the code context. | 67 | * @brief Pinpoint the code context. |
37 | * | 68 | * |
38 | * Class, holding the point in code, for instance, where the exception | 69 | * Class, holding the point in code, for instance, where the exception |
39 | * occured. | 70 | * occured. |
40 | */ | 71 | */ |
41 | class code_point { | 72 | class code_point { |
42 | public: | 73 | public: |
43 | /** | 74 | /** |
44 | * The string describing the point in code. | 75 | * The string describing the point in code. |
45 | */ | 76 | */ |
46 | string where; | 77 | string where; |
47 | /** | 78 | /** |
48 | * The file (as provided by __FILE__) if available. | 79 | * The file (as provided by __FILE__) if available. |
49 | */ | 80 | */ |
50 | string file; | 81 | string file; |
51 | /** | 82 | /** |
52 | * The function name (as provided by __PRETTY_FUNCTION__) if | 83 | * The function name (as provided by __PRETTY_FUNCTION__) if |