Packets: Fix VariantParser invalid parser access bug
[senf.git] / Utils / Exception.cci
index 84f5d7b..189c2f1 100644 (file)
 ///////////////////////////////cci.p///////////////////////////////////////
 
 ///////////////////////////////////////////////////////////////////////////
+// senf::ExceptionMixin
+
+prefix_ senf::ExceptionMixin::ExceptionMixin(std::string const & 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;
+}
+
+///////////////////////////////////////////////////////////////////////////
 // senf::Exception
+
 prefix_ senf::Exception::Exception(std::string const & description)
-    : message_(description)
+    : ExceptionMixin(description)
 {}
 
 ///////////////////////////////////////////////////////////////////////////
+// senf::SystemException
 
-prefix_ senf::SystemException::SystemException(std::string const & where)
+prefix_ senf::SystemException::SystemException(std::string const & descr _SENF_EXC_DEBUG_ARGS_ND)
 {
-    init(where, errno);
+    init(descr, errno _SENF_EXC_DEBUG_ARGS_P);
 }
 
-prefix_ senf::SystemException::SystemException(int code)
+prefix_ senf::SystemException::SystemException(int code _SENF_EXC_DEBUG_ARGS_ND)
 {
-    init("", code);
+    init("", code _SENF_EXC_DEBUG_ARGS_P);
 }
 
-prefix_ senf::SystemException::SystemException(std::string const & where, int code)
+prefix_ senf::SystemException::SystemException(std::string const & descr, int code 
+                                               _SENF_EXC_DEBUG_ARGS_ND)
 {
-    init(where, code);
+    init(descr, code _SENF_EXC_DEBUG_ARGS_P);
 }
 
 prefix_ int senf::SystemException::errorNumber()
@@ -56,7 +81,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_);
@@ -82,14 +107,6 @@ prefix_  senf::SystemException::~SystemException()
     throw()
 {}
 
-prefix_ void senf::SystemException::init(std::string const & where, int code)
-{
-    code_ = code;
-    if (! where.empty())
-        (*this) << where << ": ";
-    (*this) << "(" << code << ") " << description();
-}
-
 ///////////////////////////////cci.e///////////////////////////////////////
 #undef prefix_