summaryrefslogtreecommitdiff
path: root/src/exception.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-07-26 19:16:58 +0000
committerMike Buland <eichlan@xagasoft.com>2006-07-26 19:16:58 +0000
commit579c3ac445043122b0a702bdb2542d9ea404b62e (patch)
treea96017529296f52a357e25de37b8c4cd052bebf5 /src/exception.h
parent9e27762c2b4c1baf5b2aff003fbc56236fd742e6 (diff)
downloadlibbu++-579c3ac445043122b0a702bdb2542d9ea404b62e.tar.gz
libbu++-579c3ac445043122b0a702bdb2542d9ea404b62e.tar.bz2
libbu++-579c3ac445043122b0a702bdb2542d9ea404b62e.tar.xz
libbu++-579c3ac445043122b0a702bdb2542d9ea404b62e.zip
Exceptions have been re-worked, and are easier to use, and don't collide with
system includues anymore.
Diffstat (limited to 'src/exception.h')
-rw-r--r--src/exception.h99
1 files changed, 0 insertions, 99 deletions
diff --git a/src/exception.h b/src/exception.h
deleted file mode 100644
index 1234bef..0000000
--- a/src/exception.h
+++ /dev/null
@@ -1,99 +0,0 @@
1#ifndef EXCEPTION_H
2#define EXCEPTION_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 */
12class Exception : public std::exception
13{
14public:
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 Exception( const char *sFormat, ... ) throw();
23
24 /**
25 *
26 * @param nCode
27 * @param sFormat
28 */
29 Exception( int nCode, const char *sFormat, ... ) throw();
30
31 /**
32 *
33 * @param nCode
34 * @return
35 */
36 Exception( int nCode=0 ) throw();
37
38 /**
39 *
40 * @return
41 */
42 virtual ~Exception() 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
63private:
64 char *sWhat; /**< The text string telling people what went wrong. */
65 int nErrorCode; /**< The code for the error that occured. */
66};
67
68#define subExceptionDecl( name ) \
69class name : public Exception \
70{ \
71 public: \
72 name( const char *sFormat, ... ) throw (); \
73 name( int nCode, const char *sFormat, ... ) throw(); \
74 name( int nCode=0 ) throw (); \
75};
76
77#define subExceptionDef( name ) \
78name::name( const char *lpFormat, ... ) throw() : \
79 Exception( 0 ) \
80{ \
81 va_list ap; \
82 va_start( ap, lpFormat ); \
83 setWhat( lpFormat, ap ); \
84 va_end( ap ); \
85} \
86name::name( int nCode, const char *lpFormat, ... ) throw() : \
87 Exception( nCode ) \
88{ \
89 va_list ap; \
90 va_start( ap, lpFormat ); \
91 setWhat( lpFormat, ap ); \
92 va_end( ap ); \
93} \
94name::name( int nCode ) throw() : \
95 Exception( nCode ) \
96{ \
97}
98
99#endif