/** @file
$Id$
$Date$
$Author$
@copy © Marc Wäckerlin
@license LGPL, see file COPYING
*/
#include
#include
#include
#include
#include
namespace mrw {
/** @addtogroup grpStackTrace */
//@{
/** @defgroup AutoTrace Automated Unexpected and Terminate Handler
with Stack Trace
@brief Don't care about the unexpected handler, don't care about
a try-catch in the main, let the library do all the repetitive
work for you.
For all your programs it is recommended to implement an
identical unexpected handler, that rethrows, catches the @c
mrw::exception, @c std::exception and all unknown exceptions,
traces them and finally quits with a throw of a @c
std::bad_exception. You are also required to write a @c try @c
catch block around all in your @c main, so that you don't miss
any exception. The only thing that may be different from project
to project is, how tracing is done. The MRW C++ Class Library
provides you with additional libraries you can link to. By
linking to the library, you get an unexpected handler and an
exception trace in the @c main for free: You don't need to add a
single line of code, just link to one more library! The
libraries differ in how tracing is done.
The Implementation is done with a static instance of a class that
sets the unexpected handler in the constructor.
@section trcstderr Trace using std::cerr
If you link to the library @c libmrwexcstderr using a linker
option such as: @c -lmrwexcstderr, then an unexpected and a
terminate handler are registered, that trace to the standard
error stream @c std::cerr. Also for all know signals there's a
signal handler to trace the stack before termination (except in
case of a @c SIGTRAP, wehere the program is not terminated). You
don't need to change a single line in your code!
*/
//@{
/** @brief unexpected handler, that traces to @c std::cerr
The unexpected handler is installed automatically when you link
to @c -lmrwexcstderr. The implementation of this unexpected
handler is as follows:
@code
void unexpected_stderr() {
std::cerr<<"UNEXPECTED EXCEPTION: ----------------------------"<