Initial commit, version 0.1.0.
[libfsafe.git] / libfsafe / checkpoint.hxx
blob27f0081b895b11d1e0630c4bae8ba6cb3e8ae44d
1 /**
2 * @file
4 * Contains declaration of @ref CHECKPOINT.
5 */
7 #ifndef LIBFSAFE_CHECKPOINT_HXX
8 #define LIBFSAFE_CHECKPOINT_HXX
10 #include <libsex/utility.hxx>
11 #include <libfsafe/UnexpectedException.hxx>
13 /**
14 * Marks an important statement in the program flow.
16 * The marked statement is executed. In the default case
17 * (the statement being successfull) nothing else will
18 * happen. If the statement throws an exception, it will be
19 * wrapped into anther exception that contains the location
20 * and the statement itsself.
22 * Used to create concise backtraces that contain the
23 * original exception(s) and the most important (=marked)
24 * statements of the current call stack.
26 * @param statement The statement to mark and execute.
27 * @throws libfsafe::UnexpectedException If statement throws.
28 * @see WRAP
30 #define CHECKPOINT(statement) \
31 try { \
32 statement; \
33 } catch (libsex::Exception& e) { \
34 throw libsex::formatted<libfsafe::UnexpectedException>(e, __FILE__, __LINE__, #statement); \
37 #endif