17 #ifndef HH_SENF_Utils_Exception_ 18 #define HH_SENF_Utils_Exception_ 1 24 #include <boost/utility/enable_if.hpp> 25 #include <boost/type_traits/is_convertible.hpp> 26 #include <senf/config.hh> 135 void append(std::string text);
148 #ifdef SENF_BACKTRACE 150 std::string::size_type excLen_;
170 virtual char const * what()
const throw();
186 template <
class BaseException>
196 virtual
char const * what() const throw();
199 template <class BaseException>
217 # define SENF_WRAP_EXC(Ex) \ 218 catch (Ex const & base) { \ 219 if (dynamic_cast<senf::ExceptionMixin const *>(&base)) \ 222 throw senf::WrapException<Ex>(base); \ 225 # define SENF_WRAP_EXC_MSG(Ex, Msg) \ 226 catch (Ex const & base) { \ 227 if (dynamic_cast<senf::ExceptionMixin const *>(&base)) \ 230 throw senf::WrapException<Ex>(base) << " " << Msg; \ 233 template <
class Exc,
class Arg>
234 typename boost::enable_if< boost::is_convertible<Exc*,ExceptionMixin*>, Exc & >::type
245 # define _SENF_EXC_DEBUG_ARGS ,char const * file=0,int line=0 246 # define _SENF_EXC_DEBUG_ARGS_ND ,char const *file,int line 247 # define _SENF_EXC_DEBUG_ARGS_P ,file,line 249 # define _SENF_EXC_DEBUG_ARGS 250 # define _SENF_EXC_DEBUG_ARGS_ND 251 # define _SENF_EXC_DEBUG_ARGS_P 295 SystemException(std::string
const & descr,
int code _SENF_EXC_DEBUG_ARGS);
302 int errorNumber()
const;
303 char const * errorString()
const;
305 bool anyOf(
int c0,
int c1=0,
int c2=0,
int c3=0,
int c4=0,
int c5=0,
306 int c6=0,
int c7=0,
int c8=0,
int c9=0)
const;
316 # define SENF_EXC_DEBUGINFO ,__FILE__,__LINE__ 318 # define SENF_EXC_DEBUGINFO 321 # define SENF_THROW_SYSTEM_EXCEPTION(desc) \ 322 throw senf::SystemException(desc SENF_EXC_DEBUGINFO)
std::string backtrace() const
Return backtrace (if available)
std::ostream & operator<<(std::ostream &os, CpuStat const &cs)
void append(std::string text)
Extend exception description.
Generic extensible exception mixin.
WrapException< BaseException > make_WrapException(BaseException const &base)
unspecified_keyword_type description
ExceptionMixin(std::string const &description="")
Initialize exception with string.
#define _SENF_EXC_DEBUG_ARGS
#define _SENF_EXC_DEBUG_ARGS_ND
Wrapper for standard non-senf exceptions.
Exception handling standard UNIX errors (errno)
std::string message() const
get exception description
Extensible exception base-class.