X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FException.hh;h=c6f32572797c72dfe7ee348a4b6cee148ff0a83a;hb=b1f9349b1f3521d58cbef52ead0f2e5303a58c9e;hp=b151b883d54c15e760501d69e3a613fa63b56f9e;hpb=9ded1690d676ba7c7054a7a272debf99102f94c0;p=senf.git diff --git a/Utils/Exception.hh b/Utils/Exception.hh index b151b88..c6f3257 100644 --- a/Utils/Exception.hh +++ b/Utils/Exception.hh @@ -23,8 +23,8 @@ /** \file \brief Exception public header */ -#ifndef HH_Exception_ -#define HH_Exception_ 1 +#ifndef HH_SENF_Utils_Exception_ +#define HH_SENF_Utils_Exception_ 1 // Custom includes #include @@ -140,9 +140,10 @@ namespace senf { class ExceptionMixin { public: - std::string const & message() const; + std::string message() const; ///< get exception description + std::string backtrace() const; ///< Return backtrace (if available) - void append(std::string text); ///< Extend exception description + void append(std::string text); ///< Extend exception description /**< Adds \a text to the description text. */ protected: @@ -153,11 +154,12 @@ namespace senf { describing the exception for most derived exceptions. */ + std::string what_; private: #ifdef SENF_DEBUG void addBacktrace(); + std::string::size_type excLen_; #endif - std::string message_; }; /** \brief Extensible exception base-class @@ -177,6 +179,9 @@ namespace senf { virtual ~Exception() throw(); virtual char const * what() const throw(); + ///< get exception description and backtrace if available + /**< get description of the exception (message()) and backtrace + information if SENF is compiled with \c SENF_DEBUG */ protected: explicit Exception(std::string const & description = ""); @@ -261,7 +266,7 @@ namespace senf { the exception description: \code // Standard usage: Take \c errno from environment - SENF_THROW_SYSTEM_EXCEPTION() + SENF_THROW_SYSTEM_EXCEPTION("::open()") << " while opening configuration file: " << filename; // You may however explicitly specify the errno value @@ -299,7 +304,6 @@ namespace senf { void init(std::string const & descr, int code _SENF_EXC_DEBUG_ARGS_ND); int code_; - std::string what_; }; # ifdef SENF_DEBUG