libfsafe  0.1.1
eases writing fail-safe code (C++)
/home/ptr/dev/dev-libs/libfsafe/libfsafe/checkpoint.hxx
Go to the documentation of this file.
00001 /**
00002  * @file
00003  *
00004  * Contains declaration of @ref CHECKPOINT.
00005  */
00006 
00007 #ifndef LIBFSAFE_CHECKPOINT_HXX
00008 #define LIBFSAFE_CHECKPOINT_HXX
00009 
00010 #include <libsex/utility.hxx>
00011 #include <libfsafe/UnexpectedException.hxx>
00012 
00013 /**
00014  * Marks an important statement in the program flow.
00015  *
00016  * The marked statement is executed. In the default case
00017  * (the statement being successfull) nothing else will
00018  * happen. If the statement throws an exception, it will be
00019  * wrapped into anther exception that contains the location
00020  * and the statement itsself.
00021  *
00022  * Used to create concise backtraces that contain the
00023  * original exception(s) and the most important (=marked)
00024  * statements of the current call stack.
00025  *
00026  * @param statement The statement to mark and execute.
00027  * @throws libfsafe::UnexpectedException If statement throws.
00028  * @see WRAP
00029  */
00030 #define CHECKPOINT(statement) \
00031 try { \
00032         statement; \
00033 } catch (libsex::Exception& e) { \
00034         throw libsex::formatted<libfsafe::UnexpectedException>(e, __FILE__, __LINE__, #statement); \
00035 }
00036 
00037 #endif
 All Classes Files Defines