From: g0dil Date: Fri, 20 Oct 2006 14:30:38 +0000 (+0000) Subject: Add method argument to SystemException X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=c28e0df3accaafcc9a934275f80c80153f5a0e54;p=senf.git Add method argument to SystemException git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@147 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Utils/Exception.cc b/Utils/Exception.cc index a534910..c9a43f1 100644 --- a/Utils/Exception.cc +++ b/Utils/Exception.cc @@ -27,14 +27,24 @@ // Custom includes #include +#include #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// +prefix_ void satcom::lib::SystemException::init() +{ + std::stringstream s; + if (where) + s << where << ": "; + s << "(" << err << ") " << std::strerror(err); + buffer_ = s.str(); +} + prefix_ char const * satcom::lib::SystemException::what() const throw() { - return std::strerror(this->err); + return buffer_.c_str(); } ///////////////////////////////cc.e//////////////////////////////////////// diff --git a/Utils/Exception.hh b/Utils/Exception.hh index 6c3e8b1..1c5ca1c 100644 --- a/Utils/Exception.hh +++ b/Utils/Exception.hh @@ -25,6 +25,7 @@ // Custom includes #include +#include //#include "Exception.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -34,9 +35,18 @@ namespace lib { struct SystemException : public std::exception { - SystemException(int err_) : err(err_) {}; + explicit SystemException(int err_) : where(0), err(err_) { init(); } + SystemException(char const * where_, int err_) : where(where_), err(err_) { init(); } + virtual char const * what() const throw(); + + char const * where; int err; + + virtual ~SystemException() throw() {} + private: + void init(); + std::string buffer_; }; }}