4 #include <exception> // std::exception
5 #include <stdexcept> // std::bad_alloc
6 #include <ostream> // std::ostream
11 * @brief Resembles a generic error, stores a
12 * message and optionally references one
13 * previous error (linked list).
15 * For OO error handling you should subclass this
16 * class for every type of error. Inheriting by
17 * hand is tedious, you usally don't want to do
18 * this. There are some efficient macros in @file
21 * @note The previous exceptions, if any, will
22 * be copied by calling clone() which may
23 * in turn throw bad_alloc. In that case, a
24 * notice is appended to this message (if
25 * enough chars left) and the exception is
28 class Exception
: public std::exception
31 static const unsigned short LENGTH
= 500;
33 Exception(const char* const message
) throw();
35 const char* const message
,
36 const Exception
& previous
) throw();
37 virtual ~Exception() throw();
39 void write(std::ostream
& out
) const throw(std::ios_base::failure
);
40 void backtrace(std::ostream
& out
) const throw(std::ios_base::failure
);
42 virtual const Exception
* clone() const
43 throw(std::bad_alloc
) ;
45 virtual const char* what() const throw();
49 * @brief Copy of message passed to constructor.
51 * Length is Exception::LENGTH plus nullbyte.
53 char _message
[LENGTH
+ 1];
54 const Exception
* _previous
;
56 void _initMessage(const char* const message
);