diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
| commit | f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 (patch) | |
| tree | 13cdf64f7cf134f397a7165b7a3fe0807e37026b /src/exceptionbase.h | |
| parent | 74d4c8cd27334fc7204d5a8773deb3d424565778 (diff) | |
| download | libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.gz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.bz2 libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.xz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.zip | |
Ok, no code is left in src, it's all in src/old. We'll gradually move code back
into src as it's fixed and re-org'd. This includes tests, which, I may write a
unit test system into libbu++ just to make my life easier.
Diffstat (limited to 'src/exceptionbase.h')
| -rw-r--r-- | src/exceptionbase.h | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/src/exceptionbase.h b/src/exceptionbase.h deleted file mode 100644 index 6f1eca7..0000000 --- a/src/exceptionbase.h +++ /dev/null | |||
| @@ -1,105 +0,0 @@ | |||
| 1 | #ifndef EXCEPTION_BASE_H | ||
| 2 | #define EXCEPTION_BASE_H | ||
| 3 | |||
| 4 | #include <string> | ||
| 5 | #include <exception> | ||
| 6 | #include <stdarg.h> | ||
| 7 | |||
| 8 | /** | ||
| 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 | { | ||
| 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 | /** | ||
| 25 | * | ||
| 26 | * @param nCode | ||
| 27 | * @param sFormat | ||
| 28 | */ | ||
| 29 | ExceptionBase( int nCode, const char *sFormat, ... ) throw(); | ||
| 30 | |||
| 31 | /** | ||
| 32 | * | ||
| 33 | * @param nCode | ||
| 34 | * @return | ||
| 35 | */ | ||
| 36 | ExceptionBase( int nCode=0 ) throw(); | ||
| 37 | |||
| 38 | /** | ||
| 39 | * | ||
| 40 | * @return | ||
| 41 | */ | ||
| 42 | virtual ~ExceptionBase() throw(); | ||
| 43 | |||
| 44 | /** | ||
| 45 | * | ||
| 46 | * @return | ||
| 47 | */ | ||
| 48 | virtual const char *what() const throw(); | ||
| 49 | |||
| 50 | /** | ||
| 51 | * | ||
| 52 | * @return | ||
| 53 | */ | ||
| 54 | int getErrorCode(); | ||
| 55 | |||
| 56 | /** | ||
| 57 | * | ||
| 58 | * @param lpFormat | ||
| 59 | * @param vargs | ||
| 60 | */ | ||
| 61 | void setWhat( const char *lpFormat, va_list &vargs ); | ||
| 62 | |||
| 63 | /** | ||
| 64 | * | ||
| 65 | * @param lpText | ||
| 66 | */ | ||
| 67 | void setWhat( const char *lpText ); | ||
| 68 | |||
| 69 | private: | ||
| 70 | int nErrorCode; /**< The code for the error that occured. */ | ||
| 71 | char *sWhat; /**< The text string telling people what went wrong. */ | ||
| 72 | }; | ||
| 73 | |||
| 74 | #define subExceptionDecl( name ) \ | ||
| 75 | class name : public ExceptionBase \ | ||
| 76 | { \ | ||
| 77 | public: \ | ||
| 78 | name( const char *sFormat, ... ) throw (); \ | ||
| 79 | name( int nCode, const char *sFormat, ... ) throw(); \ | ||
| 80 | name( int nCode=0 ) throw (); \ | ||
| 81 | }; | ||
| 82 | |||
| 83 | #define subExceptionDef( name ) \ | ||
| 84 | name::name( const char *lpFormat, ... ) throw() : \ | ||
| 85 | ExceptionBase( 0 ) \ | ||
| 86 | { \ | ||
| 87 | va_list ap; \ | ||
| 88 | va_start( ap, lpFormat ); \ | ||
| 89 | setWhat( lpFormat, ap ); \ | ||
| 90 | va_end( ap ); \ | ||
| 91 | } \ | ||
| 92 | name::name( int nCode, const char *lpFormat, ... ) throw() : \ | ||
| 93 | ExceptionBase( nCode ) \ | ||
| 94 | { \ | ||
| 95 | va_list ap; \ | ||
| 96 | va_start( ap, lpFormat ); \ | ||
| 97 | setWhat( lpFormat, ap ); \ | ||
| 98 | va_end( ap ); \ | ||
| 99 | } \ | ||
| 100 | name::name( int nCode ) throw() : \ | ||
| 101 | ExceptionBase( nCode ) \ | ||
| 102 | { \ | ||
| 103 | } | ||
| 104 | |||
| 105 | #endif | ||
