X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FException.cci;h=40d89a5f6106aff1326a4ac74c0a5c4800f1c5df;hb=62da0fc2f859a98e105b45859c346750a1435ebb;hp=9903becd7037329f25382d27b2505ed49b100450;hpb=96d3a2a43b4e6d7693a136a3adeb099440f19068;p=senf.git diff --git a/Utils/Exception.cci b/Utils/Exception.cci index 9903bec..40d89a5 100644 --- a/Utils/Exception.cci +++ b/Utils/Exception.cci @@ -27,43 +27,28 @@ #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// -prefix_ senf::SystemException::SystemException() - : where_(0), code_(errno) -{ - init(); -} - -prefix_ senf::SystemException::SystemException(int code) - : where_(0), code_(code) -{ - init(); -} - -prefix_ senf::SystemException::SystemException(char const * where) - : where_(where), code_(errno) -{ - init(); -} +prefix_ senf::SystemException::SystemException(SystemException const & other) + : std::stringstream(other.str(),std::ios::out), code_(other.code_) +{} -prefix_ senf::SystemException::SystemException(char const * where, int code) - : where_(where), code_(code) +prefix_ senf::SystemException::SystemException(std::string const & where, int code) + : std::stringstream(std::ios::out), code_(code) { - init(); + if (! where.empty()) + (*this) << where << ": "; + (*this) << "(" << code_ << ") " << description(); } prefix_ char const * senf::SystemException::what() const throw() { + /// \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(); } -prefix_ char const * senf::SystemException::where() - const -{ - return where_; -} - -prefix_ int senf::SystemException::code() +prefix_ int senf::SystemException::errorNumber() const { return code_; @@ -97,17 +82,17 @@ prefix_ senf::SystemException::~SystemException() prefix_ void senf::throwErrno() { - throwErrno(0, errno); + throwErrno("", errno); } -prefix_ void senf::throwErrno(char const * where) +prefix_ void senf::throwErrno(std::string const & where) { throwErrno(where, errno); } prefix_ void senf::throwErrno(int code) { - throwErrno(0, code); + throwErrno("", code); } ///////////////////////////////cci.e///////////////////////////////////////