libsex  3.1.0
simple exception library (C++)
/home/ptr/dev/dev-libs/libsex/libsex/throw.hxx
Go to the documentation of this file.
00001 /**
00002  * @file
00003  *
00004  * Macros related to throwing exceptions.
00005  */
00006 
00007 #ifndef LIBSEX_THROW_HXX
00008 #define LIBSEX_THROW_HXX
00009 
00010 #include <libsex/utility.hxx>
00011 
00012 /**
00013  * Macro to throw an exception without any argument.
00014  *
00015  * File name and line number are inserted automatically.
00016  *
00017  * @param class Which exception to throw.
00018  */
00019 #define THROW_ARGLESS(class) \
00020 { \
00021         throw libsex::formatted<class>(__FILE__, __LINE__); \
00022 }
00023 
00024 /**
00025  * Macro to throw an exception with arguments.
00026  *
00027  * @param class Which exception to throw.
00028  * @param args... Arguments for message template.
00029  * @see THROW_ARGLESS()
00030  */
00031 #define THROW(class, args...) \
00032 { \
00033         throw libsex::formatted<class>(__FILE__, __LINE__, ##args); \
00034 }
00035 
00036 /**
00037  * Macro to throw another exception when an exception has
00038  * been caught.
00039  *
00040  * Chains the previous exception and the newly created one
00041  * together.
00042  *
00043  * @note The previous exception has to be accessible in
00044  *       this scope via the variable name @c e.
00045  *
00046  * @param class   Which exception to throw.
00047  * @param args... Arguments for message template.
00048  * @see THROW
00049  */
00050 #define CHAIN(class, args...) \
00051 {\
00052         throw libsex::formatted<class>(e, __FILE__, __LINE__, ##args); \
00053 }
00054 
00055 #endif
 All Classes Files Functions Variables Defines