Packets: Fix VariantParser invalid parser access bug
[senf.git] / Utils / Exception.cci
index 9903bec..189c2f1 100644 (file)
 #define prefix_ inline
 ///////////////////////////////cci.p///////////////////////////////////////
 
-prefix_ senf::SystemException::SystemException()
-    : where_(0), code_(errno)
+///////////////////////////////////////////////////////////////////////////
+// senf::ExceptionMixin
+
+prefix_ senf::ExceptionMixin::ExceptionMixin(std::string const & 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;
 }
 
-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 +107,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_