Просмотр исходного кода

ENH: PluginFramework: nicer exception error messages

Sascha Zelzer лет назад: 15
Родитель
Сommit
2bed1f1263

+ 10 - 0
Libs/PluginFramework/ctkPluginException.cpp

@@ -67,6 +67,16 @@ ctkPluginException::Type ctkPluginException::getType() const
   return type;
 }
 
+const char* ctkPluginException::what() const throw()
+{
+  static std::string fullMsg;
+  fullMsg = std::string(std::runtime_error::what());
+  const char* causeMsg = getCause().what();
+  if (causeMsg) fullMsg += std::string("\n  Caused by: ") + causeMsg;
+
+  return fullMsg.c_str();
+}
+
 
 QDebug operator<<(QDebug dbg, const ctkPluginException& exc)
 {

+ 2 - 0
Libs/PluginFramework/ctkPluginException.h

@@ -86,6 +86,8 @@ public:
   void setCause(const std::exception&) throw(std::logic_error);
   Type getType() const;
 
+  const char* what() const throw();
+
 
 private: