Added RETHROW macro, functionality, tests, examples, etc.
[libsex.git] / include / libsex / throw.hxx
blob036d10381374c043df97fdf57f2777cdd7777f55
1 #ifndef LIBSEX_THROW_HXX
2 #define LIBSEX_THROW_HXX
4 #include <libsex/utility.hxx>
6 /**
7 * Macro to throw an exception.
9 * File name and line number are inserted automatically.
11 * @param class Which exception to throw.
12 * @param args... Optional. Arguments for message template.
14 #define THROW(class, args...) \
15 { \
16 throw libsex::formatted<class>(__FILE__, __LINE__, ##args); \
19 /**
20 * Macro to throw another exception when an exception has
21 * been caught.
23 * Chains the previous exception and the newly created one
24 * together.
26 * @see THROW
28 #define RETHROW(class, args...) \
30 throw libsex::formatted<class>(e, __FILE__, __LINE__, ##args); \
33 #endif