X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FException.cci;h=189c2f1e24f21f47ff8433f24eaad4494fd6d546;hb=1b1d76302a5d61e918ef71f1c8e11f80ac1262e2;hp=9c3a383a48c3cd06fe834f0f3ec4436d5d6bbda7;hpb=145f6a7d0f3a6aaa77b3625351c952d24cb0b8a1;p=senf.git diff --git a/Utils/Exception.cci b/Utils/Exception.cci index 9c3a383..189c2f1 100644 --- a/Utils/Exception.cci +++ b/Utils/Exception.cci @@ -21,20 +21,86 @@ \brief Exception inline non-template implementation */ // Custom includes +#include +#include #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// -prefix_ senf::SystemException::SystemException(int err_) - : where(0), err(err_) +/////////////////////////////////////////////////////////////////////////// +// senf::ExceptionMixin + +prefix_ senf::ExceptionMixin::ExceptionMixin(std::string const & description) + : message_(description) +{ +#ifdef SENF_DEBUG + addBacktrace(); +#endif +} + +prefix_ std::string const & senf::ExceptionMixin::message() + const +{ + return message_; +} + +prefix_ void senf::ExceptionMixin::append(std::string text) +{ + message_ += text; +} + +/////////////////////////////////////////////////////////////////////////// +// senf::Exception + +prefix_ senf::Exception::Exception(std::string const & description) + : ExceptionMixin(description) +{} + +/////////////////////////////////////////////////////////////////////////// +// senf::SystemException + +prefix_ senf::SystemException::SystemException(std::string const & descr _SENF_EXC_DEBUG_ARGS_ND) +{ + init(descr, errno _SENF_EXC_DEBUG_ARGS_P); +} + +prefix_ senf::SystemException::SystemException(int code _SENF_EXC_DEBUG_ARGS_ND) +{ + init("", code _SENF_EXC_DEBUG_ARGS_P); +} + +prefix_ senf::SystemException::SystemException(std::string const & descr, int code + _SENF_EXC_DEBUG_ARGS_ND) +{ + init(descr, code _SENF_EXC_DEBUG_ARGS_P); +} + +prefix_ int senf::SystemException::errorNumber() + const +{ + return code_; +} + +prefix_ char const * senf::SystemException::errorString() + const { - init(); + return std::strerror(code_); } -prefix_ senf::SystemException::SystemException(char const * where_, int err_) - : where(where_), err(err_) +prefix_ bool senf::SystemException::anyOf(int c0, int c1, int c2, int c3, int c4, int c5, + int c6, int c7, int c8, int c9) { - init(); + return + (c0 && code_ == c0) || + (c1 && code_ == c1) || + (c2 && code_ == c2) || + (c3 && code_ == c3) || + (c4 && code_ == c4) || + (c5 && code_ == c5) || + (c6 && code_ == c6) || + (c7 && code_ == c7) || + (c8 && code_ == c8) || + (c9 && code_ == c9); } prefix_ senf::SystemException::~SystemException()