4 * Macros related to throwing exceptions.
7 #ifndef LIBSEX_THROW_HXX
8 #define LIBSEX_THROW_HXX
10 #include <libsex/utility.hxx>
13 * Macro to throw an exception without any argument.
15 * File name and line number are inserted automatically.
17 * @param class Which exception to throw.
19 #define THROW_ARGLESS(class) \
21 throw libsex::formatted<class>(__FILE__, __LINE__); \
25 * Macro to throw an exception with arguments.
27 * @param class Which exception to throw.
28 * @param args... Arguments for message template.
29 * @see THROW_ARGLESS()
31 #define THROW(class, args...) \
33 throw libsex::formatted<class>(__FILE__, __LINE__, ##args); \
37 * Macro to throw another exception when an exception has
40 * Chains the previous exception and the newly created one
43 * @note The previous exception has to be accessible in
44 * this scope via the variable name @c e.
46 * @param class Which exception to throw.
47 * @param args... Arguments for message template.
50 #define CHAIN(class, args...) \
52 throw libsex::formatted<class>(e, __FILE__, __LINE__, ##args); \