浏览代码

ENH: PluginFramework: nicer exception error messages

Sascha Zelzer 15 年之前
父节点
当前提交
2bed1f1263
共有 2 个文件被更改,包括 12 次插入0 次删除
  1. 10 0
      Libs/PluginFramework/ctkPluginException.cpp
  2. 2 0
      Libs/PluginFramework/ctkPluginException.h

+ 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: