소스 검색

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: