diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-07-03 00:28:59 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-07-03 00:28:59 +0000 |
commit | ac517a2b7625e0aa0862679e961c6349f859ea3b (patch) | |
tree | e3e27a6b9bd5e2be6150088495c91fc91786ad9d /src/exceptionbase.h | |
parent | f8d4301e9fa4f3709258505941e37fab2eadadc6 (diff) | |
parent | bd865cee5f89116c1f054cd0e5c275e97c2d0a9b (diff) | |
download | libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.gz libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.bz2 libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.xz libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.zip |
The reorg is being put in trunk, I think it's ready. Now we just get to find
out how many applications won't work anymore :)
Diffstat (limited to '')
-rw-r--r-- | src/exceptionbase.h | 127 |
1 files changed, 68 insertions, 59 deletions
diff --git a/src/exceptionbase.h b/src/exceptionbase.h index 6f1eca7..24e4bbf 100644 --- a/src/exceptionbase.h +++ b/src/exceptionbase.h | |||
@@ -1,75 +1,84 @@ | |||
1 | #ifndef EXCEPTION_BASE_H | 1 | #ifndef BU_EXCEPTION_BASE_H |
2 | #define EXCEPTION_BASE_H | 2 | #define BU_EXCEPTION_BASE_H |
3 | 3 | ||
4 | #include <string> | 4 | #include <string> |
5 | #include <exception> | 5 | #include <exception> |
6 | #include <stdarg.h> | 6 | #include <stdarg.h> |
7 | 7 | ||
8 | /** | 8 | namespace Bu |
9 | * A generalized Exception base class. This is nice for making general and | ||
10 | * flexible child classes that can create new error code classes. | ||
11 | */ | ||
12 | class ExceptionBase : public std::exception | ||
13 | { | 9 | { |
14 | public: | ||
15 | /** | ||
16 | * Construct an exception with an error code of zero, but with a | ||
17 | * description. The use of this is not reccomended most of the time, it's | ||
18 | * generally best to include an error code with the exception so your | ||
19 | * program can handle the exception in a better way. | ||
20 | * @param sFormat The format of the text. See printf for more info. | ||
21 | */ | ||
22 | ExceptionBase( const char *sFormat, ... ) throw(); | ||
23 | |||
24 | /** | 10 | /** |
11 | * A generalized Exception base class. This is nice for making general and | ||
12 | * flexible child classes that can create new error code classes. | ||
13 | * | ||
14 | * In order to create your own exception class use these two lines. | ||
25 | * | 15 | * |
26 | * @param nCode | 16 | * in your header: subExceptionDecl( NewClassName ); |
27 | * @param sFormat | ||
28 | */ | ||
29 | ExceptionBase( int nCode, const char *sFormat, ... ) throw(); | ||
30 | |||
31 | /** | ||
32 | * | 17 | * |
33 | * @param nCode | 18 | * in your source: subExcpetienDef( NewClassName ); |
34 | * @return | ||
35 | */ | 19 | */ |
36 | ExceptionBase( int nCode=0 ) throw(); | 20 | class ExceptionBase : public std::exception |
37 | 21 | { | |
38 | /** | 22 | public: |
39 | * | 23 | /** |
40 | * @return | 24 | * Construct an exception with an error code of zero, but with a |
41 | */ | 25 | * description. The use of this is not reccomended most of the time, |
42 | virtual ~ExceptionBase() throw(); | 26 | * it's generally best to include an error code with the exception so |
27 | * your program can handle the exception in a better way. | ||
28 | * @param sFormat The format of the text. See printf for more info. | ||
29 | */ | ||
30 | ExceptionBase( const char *sFormat, ... ) throw(); | ||
31 | |||
32 | /** | ||
33 | * | ||
34 | * @param nCode | ||
35 | * @param sFormat | ||
36 | */ | ||
37 | ExceptionBase( int nCode, const char *sFormat, ... ) throw(); | ||
38 | |||
39 | /** | ||
40 | * | ||
41 | * @param nCode | ||
42 | * @return | ||
43 | */ | ||
44 | ExceptionBase( int nCode=0 ) throw(); | ||
45 | |||
46 | /** | ||
47 | * | ||
48 | * @return | ||
49 | */ | ||
50 | virtual ~ExceptionBase() throw(); | ||
43 | 51 | ||
44 | /** | 52 | /** |
45 | * | 53 | * |
46 | * @return | 54 | * @return |
47 | */ | 55 | */ |
48 | virtual const char *what() const throw(); | 56 | virtual const char *what() const throw(); |
49 | 57 | ||
50 | /** | 58 | /** |
51 | * | 59 | * |
52 | * @return | 60 | * @return |
53 | */ | 61 | */ |
54 | int getErrorCode(); | 62 | int getErrorCode(); |
55 | 63 | ||
56 | /** | 64 | /** |
57 | * | 65 | * |
58 | * @param lpFormat | 66 | * @param lpFormat |
59 | * @param vargs | 67 | * @param vargs |
60 | */ | 68 | */ |
61 | void setWhat( const char *lpFormat, va_list &vargs ); | 69 | void setWhat( const char *lpFormat, va_list &vargs ); |
62 | 70 | ||
63 | /** | 71 | /** |
64 | * | 72 | * |
65 | * @param lpText | 73 | * @param lpText |
66 | */ | 74 | */ |
67 | void setWhat( const char *lpText ); | 75 | void setWhat( const char *lpText ); |
68 | 76 | ||
69 | private: | 77 | private: |
70 | int nErrorCode; /**< The code for the error that occured. */ | 78 | int nErrorCode; /**< The code for the error that occured. */ |
71 | char *sWhat; /**< The text string telling people what went wrong. */ | 79 | char *sWhat; /**< The text string telling people what went wrong. */ |
72 | }; | 80 | }; |
81 | } | ||
73 | 82 | ||
74 | #define subExceptionDecl( name ) \ | 83 | #define subExceptionDecl( name ) \ |
75 | class name : public ExceptionBase \ | 84 | class name : public ExceptionBase \ |