From a012e8fde1c3159a225a620d5fa0c077d3b210dd Mon Sep 17 00:00:00 2001
From: g0dil <g0dil@wiback.org>
Date: Fri, 20 Oct 2006 14:30:38 +0000
Subject: [PATCH] Add method argument to SystemException

---
 Utils/Exception.cc | 12 +++++++++++-
 Utils/Exception.hh | 12 +++++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/Utils/Exception.cc b/Utils/Exception.cc
index a53491001..c9a43f111 100644
--- a/Utils/Exception.cc
+++ b/Utils/Exception.cc
@@ -27,14 +27,24 @@
 
 // Custom includes
 #include <cstring>
+#include <sstream>
 
 #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 6c3e8b13e..1c5ca1ca7 100644
--- a/Utils/Exception.hh
+++ b/Utils/Exception.hh
@@ -25,6 +25,7 @@
 
 // Custom includes
 #include <exception>
+#include <string>
 
 //#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_;
     };
     
 }}
-- 
GitLab