-rw-r--r-- | include/konforka/exception.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/konforka/exception.h b/include/konforka/exception.h index 5e0bf96..dbfe27c 100644 --- a/include/konforka/exception.h +++ b/include/konforka/exception.h @@ -5,48 +5,79 @@ #include <string> #include <list> /** * @file * @brief exception-related stuff. * * Basic exception-related declarations and definitions. */ /** * @def CODEPOINT * the convenience definition of the parameters passed to the * konforka::code_point constructor. */ #define CODEPOINT __FILE__,__PRETTY_FUNCTION__,__LINE__ /** * @def NOCODEPOINT * the convenience definition for the codepoint denoting no particular point in * code. */ #define NOCODEPOINT "no information" /** + * @def KONFORKA_RETHROW + * the convenience definition for seeing the exception and rethrowing it further. + */ +#define KONFORKA_RETHROW catch(konforka::exception& e) { e.see(CODEPOINT); throw; } + +/** + * @def KONFORKA_E_ARGS + * the convenience definition for naming codepoint parameters + */ +#define KONFORKA_E_PARS const string& fi,const string& fu,int l,const string& w + +/** + * @def KONFORKA_E_CONS + * the convenience definition for passing parameters to constructor + */ +#define KONFORKA_E_CONS fi,fu,l,w + +/** + * @def KONFORKA_E_SUBCLASS + * the convenience definition for subclassing konforka exceptions + * @param base base class + * @param derived derived class + */ +#define KONFORKA_E_SUBCLASS(derived,base) \ + class derived : public base { \ + public: \ + explicit derived(KONFORKA_E_PARS) \ + : base(KONFORKA_E_CONS) { } \ + } + +/** * @brief The main konforka namespace. */ namespace konforka { using std::string; using std::list; /** * @brief Pinpoint the code context. * * Class, holding the point in code, for instance, where the exception * occured. */ class code_point { public: /** * The string describing the point in code. */ string where; /** * The file (as provided by __FILE__) if available. */ string file; /** * The function name (as provided by __PRETTY_FUNCTION__) if |