X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FException.cci;h=3366fe23467d20109a35c3d00a3e941169c142ea;hb=bd9f9d3fd6fbcff0112a7bf48ab9284da9576b11;hp=9903becd7037329f25382d27b2505ed49b100450;hpb=96d3a2a43b4e6d7693a136a3adeb099440f19068;p=senf.git diff --git a/Utils/Exception.cci b/Utils/Exception.cci index 9903bec..3366fe2 100644 --- a/Utils/Exception.cci +++ b/Utils/Exception.cci @@ -27,49 +27,63 @@ #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// -prefix_ senf::SystemException::SystemException() - : where_(0), code_(errno) +/////////////////////////////////////////////////////////////////////////// +// senf::ExceptionMixin + +prefix_ senf::ExceptionMixin::ExceptionMixin(std::string const & description) + : what_(description), + message_(description) { - init(); +#ifdef SENF_DEBUG + addBacktrace(); +#endif } -prefix_ senf::SystemException::SystemException(int code) - : where_(0), code_(code) +prefix_ std::string const & senf::ExceptionMixin::message() + const { - init(); + return message_; } -prefix_ senf::SystemException::SystemException(char const * where) - : where_(where), code_(errno) +prefix_ void senf::ExceptionMixin::append(std::string text) { - init(); + message_ += text; + what_ += text; } -prefix_ senf::SystemException::SystemException(char const * where, int code) - : where_(where), code_(code) +/////////////////////////////////////////////////////////////////////////// +// 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(); + 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) { - return buffer_.c_str(); + init("", code _SENF_EXC_DEBUG_ARGS_P); } -prefix_ char const * senf::SystemException::where() - const +prefix_ senf::SystemException::SystemException(std::string const & descr, int code + _SENF_EXC_DEBUG_ARGS_ND) { - return where_; + init(descr, code _SENF_EXC_DEBUG_ARGS_P); } -prefix_ int senf::SystemException::code() +prefix_ int senf::SystemException::errorNumber() const { return code_; } -prefix_ char const * senf::SystemException::description() +prefix_ char const * senf::SystemException::errorString() const { return std::strerror(code_); @@ -95,21 +109,6 @@ prefix_ senf::SystemException::~SystemException() throw() {} -prefix_ void senf::throwErrno() -{ - throwErrno(0, errno); -} - -prefix_ void senf::throwErrno(char const * where) -{ - throwErrno(where, errno); -} - -prefix_ void senf::throwErrno(int code) -{ - throwErrno(0, code); -} - ///////////////////////////////cci.e/////////////////////////////////////// #undef prefix_