Sfoglia il codice sorgente

Added qDebug() stream operator for ctkRuntimeException.

Sascha Zelzer 13 anni fa
parent
commit
ac69b0273b

+ 10 - 0
Libs/PluginFramework/ctkRuntimeException.cpp

@@ -22,6 +22,8 @@
 
 #include "ctkRuntimeException.h"
 
+#include <QDebug>
+
 //----------------------------------------------------------------------------
 ctkRuntimeException::ctkRuntimeException(const QString& msg, const std::exception* cause)
   : std::runtime_error(msg.toStdString())
@@ -71,3 +73,11 @@ const char* ctkRuntimeException::what() const throw()
 
   return fullMsg.c_str();
 }
+
+//----------------------------------------------------------------------------
+QDebug operator<<(QDebug dbg, const ctkRuntimeException& exc)
+{
+  dbg << "ctkRuntimeException:" << exc.what();
+
+  return dbg.maybeSpace();
+}

+ 6 - 0
Libs/PluginFramework/ctkRuntimeException.h

@@ -57,4 +57,10 @@ private:
  * \ingroup PluginFramework
  */
 typedef ctkRuntimeException ctkIllegalStateException;
+
+/**
+ * \ingroup PluginFramework
+ */
+CTK_PLUGINFW_EXPORT QDebug operator<<(QDebug dbg, const ctkRuntimeException& exc);
+
 #endif // CTKRUNTIMEEXCEPTION_H