Renamed RETHROW to CHAIN and improved its doc.
[libsex.git] / include / libsex / throw.hxx
blob3e6fb17b448aa7517770f66527a399c6e4c64470
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 * @note The previous exception has to be accessible in
27 * this scope via the variable name @c e.
29 * @see THROW
31 #define CHAIN(class, args...) \
33 throw libsex::formatted<class>(e, __FILE__, __LINE__, ##args); \
36 #endif