Packets: Fix VariantParser invalid parser access bug
[senf.git] / Utils / Exception.cti
index 3588cdc..ea12370 100644 (file)
 #define prefix_ inline
 ///////////////////////////////cti.p///////////////////////////////////////
 
-template <class Arg>
-prefix_ senf::Exception & senf::Exception::operator<<(Arg const & arg)
+template <class Exc, class Arg>
+prefix_ typename boost::enable_if< boost::is_convertible<Exc*,senf::ExceptionMixin*>, Exc & >::type
+senf::operator<<(Exc const & exc, Arg const & arg)
 {
-    message_ += boost::lexical_cast<std::string>(arg);
-    return *this;
+    const_cast<Exc &>(exc).append( boost::lexical_cast<std::string>(arg) );
+    return const_cast<Exc &>(exc);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::WrapExcecption<BaseException>
+
+template <class BaseException>
+prefix_ senf::WrapException<BaseException>::WrapException(BaseException const & base)
+    : ExceptionMixin(base.what()), BaseException(base)
+{}
+
+template <class BaseException>
+prefix_ senf::WrapException<BaseException>::~WrapException()
+    throw()
+{}
+
+template <class BaseException>
+prefix_ char const * senf::WrapException<BaseException>::what()
+    const throw()
+{
+    return message().c_str();
 }
 
 /////////////////////////////cti.e///////////////////////////////////////