/** \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 <exception>
SENF_WRAP_EXC(std::bad_cast)
SENF_WRAP_EXC(somelib::FooException)
}
- \endcode The re-thrown exception can then be caught as <tt>std::bad_cast</tt> or as
- senf::ExceptionMixin as needed. It is safe, to wrap an exception twice (the macro will detect
- this case).
+ \endcode
+ The re-thrown exception can then be caught as <tt>std::bad_cast</tt> or as senf::ExceptionMixin
+ as needed. It is safe, to wrap an exception twice (the macro will detect this case).
\code
bar() {
try {
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:
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
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 = "");
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
void init(std::string const & descr, int code _SENF_EXC_DEBUG_ARGS_ND);
int code_;
- std::string what_;
};
# ifdef SENF_DEBUG
# define SENF_EXC_DEBUGINFO
# endif
-# define SENF_THROW_SYSTEM_EXCEPTION(desc) throw SystemException(desc SENF_EXC_DEBUGINFO)
+# define SENF_THROW_SYSTEM_EXCEPTION(desc) throw senf::SystemException(desc SENF_EXC_DEBUGINFO)
}