Browse Source

fixed wrong return type of operator<<() for BaseException. Templates FTW!

tempestpy_adaptions
gereon 12 years ago
parent
commit
cc1441ce26
  1. 5
      src/exceptions/BaseException.h
  2. 2
      src/exceptions/InvalidSettings.h
  3. 2
      src/mrmc.cpp

5
src/exceptions/BaseException.h

@ -7,6 +7,7 @@
namespace mrmc {
namespace exceptions {
template<typename E>
class BaseException : public std::exception
{
public:
@ -19,10 +20,10 @@ class BaseException : public std::exception
~BaseException() throw() { }
template<class T>
BaseException& operator<<(const T& var)
E& operator<<(const T& var)
{
this->stream << var;
return *this;
return * dynamic_cast<E*>(this);
}
virtual const char* what() const throw()

2
src/exceptions/InvalidSettings.h

@ -6,7 +6,7 @@
namespace mrmc {
namespace exceptions {
class InvalidSettings : public BaseException
class InvalidSettings : public BaseException<InvalidSettings>
{
};

2
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;

Loading…
Cancel
Save