X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FException.cci;h=3366fe23467d20109a35c3d00a3e941169c142ea;hb=fd3a0e8ac95d1158e9ea661ddf9187b67c70169f;hp=40d89a5f6106aff1326a4ac74c0a5c4800f1c5df;hpb=d267cc9325ff49f1ef76aa7ddf6b51ceaafd3026;p=senf.git diff --git a/Utils/Exception.cci b/Utils/Exception.cci index 40d89a5..3366fe2 100644 --- a/Utils/Exception.cci +++ b/Utils/Exception.cci @@ -27,25 +27,54 @@ #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// -prefix_ senf::SystemException::SystemException(SystemException const & other) - : std::stringstream(other.str(),std::ios::out), code_(other.code_) +/////////////////////////////////////////////////////////////////////////// +// senf::ExceptionMixin + +prefix_ senf::ExceptionMixin::ExceptionMixin(std::string const & description) + : what_(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; + what_ += text; +} + +/////////////////////////////////////////////////////////////////////////// +// senf::Exception + +prefix_ senf::Exception::Exception(std::string const & description) + : ExceptionMixin(description) {} -prefix_ senf::SystemException::SystemException(std::string const & where, int code) - : std::stringstream(std::ios::out), code_(code) +/////////////////////////////////////////////////////////////////////////// +// senf::SystemException + +prefix_ senf::SystemException::SystemException(std::string const & descr _SENF_EXC_DEBUG_ARGS_ND) { - if (! where.empty()) - (*this) << where << ": "; - (*this) << "(" << code_ << ") " << description(); + init(descr, errno _SENF_EXC_DEBUG_ARGS_P); } -prefix_ char const * senf::SystemException::what() - const throw() +prefix_ senf::SystemException::SystemException(int code _SENF_EXC_DEBUG_ARGS_ND) { - /// \fixme Replace the 'stringstream' base-class with our own stream with a specialized - /// streambuf which allows to efficiently access the contents as a C string. - buffer_ = this->str(); - return buffer_.c_str(); + 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() @@ -54,7 +83,7 @@ prefix_ int senf::SystemException::errorNumber() return code_; } -prefix_ char const * senf::SystemException::description() +prefix_ char const * senf::SystemException::errorString() const { return std::strerror(code_); @@ -80,21 +109,6 @@ prefix_ senf::SystemException::~SystemException() throw() {} -prefix_ void senf::throwErrno() -{ - throwErrno("", errno); -} - -prefix_ void senf::throwErrno(std::string const & where) -{ - throwErrno(where, errno); -} - -prefix_ void senf::throwErrno(int code) -{ - throwErrno("", code); -} - ///////////////////////////////cci.e/////////////////////////////////////// #undef prefix_