Tools.h++ Manual
18-8 104011 Tandem Computers Incorporated
18
As you can see, the hierarchy parallels the error model outlined in previous
sections. This hierarchy assumes the presence of class
xmsg
, nominally
provided by your compiler vendor. This is a class that is being considered for
standardization by the Library Working Group of the C++ Standardization
Committee X3J16 (document 92-0116). If your compiler does not come with
versions of
xmsg
and
xalloc
, then the Tools.h++ classes
RWxmsg
and
RWxalloc
emulate them.
Class
xmsg
carries a string that can be printed out at the catch site to give the
user some idea of what went wrong. This string is formatted and
internationalized by the specializing versions of
xmsg
as described in
“Localizing messages” on page 9 in Chapter 19, “Implementation Notes.”
Error handlers
When Tools.h++ throws an exception it does so using the macro
RWTHROW
. If
your compiler supports exceptions then this macro is defined as follows:
#define RWTHROW(a) throw a
and a true exception will be thrown. Otherwise, if your compiler does not
support exceptions, then it will call an error handler with prototype:
void errHandler(const RWxmsg&);
The default error handler aborts the program. You can change the default
handler with the function
typedef void (*rwErrHandler)(const RWxmsg&);
rwErrHandler rwSetErrHandler(rwErrHandler);
18.4 Debug version of the library
Tools.h++ can be built in a “debug” mode. This is a very powerful tool for
uncovering and correcting internal errors in your code.
To build a debug version of the library, the entire library must be compiled
with the preprocessor flag "
RWDEBUG
" defined. The entire library must be
compiled with a single setting of the flag—either defined or not defined. The resultant
library will be slightly larger and slightly slower. See the appropriate makefile
for additional directions.