Added THROW_ARGLESS and improved doc.
[libsex.git] / source / throw.hxx
blob7f818476e2f59fc86e7ea0b60ecdd679877ff098
1 #ifndef LIBSEX_THROW_HXX
2 #define LIBSEX_THROW_HXX
4 #include <source/utility.hxx>
6 /**
7 * Macro to throw an exception without any argument.
9 * File name and line number are inserted automatically.
11 * @param class Which exception to throw.
13 #define THROW_ARGLESS(class) \
14 { \
15 throw libsex::formatted<class>(__FILE__, __LINE__); \
18 /**
19 * Macro to throw an exception with arguments.
21 * @see THROW_ARGLESS()
22 * @param args... Arguments for message template.
24 #define THROW(class, args...) \
25 { \
26 throw libsex::formatted<class>(__FILE__, __LINE__, ##args); \
29 /**
30 * Macro to throw another exception when an exception has
31 * been caught.
33 * Chains the previous exception and the newly created one
34 * together.
36 * @note The previous exception has to be accessible in
37 * this scope via the variable name @c e.
39 * @see THROW
41 #define CHAIN(class, args...) \
43 throw libsex::formatted<class>(e, __FILE__, __LINE__, ##args); \
46 #endif