diff --git a/src/exceptions/BaseException.h b/src/exceptions/BaseException.h index 1f61c8338..cfba4218e 100644 --- a/src/exceptions/BaseException.h +++ b/src/exceptions/BaseException.h @@ -7,6 +7,7 @@ namespace mrmc { namespace exceptions { +template class BaseException : public std::exception { public: @@ -19,10 +20,10 @@ class BaseException : public std::exception ~BaseException() throw() { } template - BaseException& operator<<(const T& var) + E& operator<<(const T& var) { this->stream << var; - return *this; + return * dynamic_cast(this); } virtual const char* what() const throw() diff --git a/src/exceptions/InvalidSettings.h b/src/exceptions/InvalidSettings.h index 2e34a7419..0ac7b14b8 100644 --- a/src/exceptions/InvalidSettings.h +++ b/src/exceptions/InvalidSettings.h @@ -6,7 +6,7 @@ namespace mrmc { namespace exceptions { -class InvalidSettings : public BaseException +class InvalidSettings : public BaseException { }; diff --git a/src/mrmc.cpp b/src/mrmc.cpp index 2b21f1cc6..757fc44d9 100644 --- a/src/mrmc.cpp +++ b/src/mrmc.cpp @@ -75,7 +75,7 @@ int main(const int argc, const char* argv[]) { try { s = mrmc::settings::newInstance(argc, argv, nullptr); - } catch (mrmc::exceptions::InvalidSettings& e) { + } catch (mrmc::exceptions::InvalidSettings e) { LOG4CPLUS_FATAL(logger, "InvalidSettings error: " << e.what()); LOG4CPLUS_FATAL(logger, "Could not recover from settings error, terminating."); std::cout << "Could not recover from settings error: " << e.what() << std::endl;