Преглед на файлове

Change ctkPluginDatabaseException to use ctkRuntimeException.

Sascha Zelzer преди 14 години
родител
ревизия
e0823fdc7a
променени са 2 файла, в които са добавени 13 реда и са изтрити 39 реда
  1. 8 25
      Libs/PluginFramework/ctkPluginDatabaseException.cpp
  2. 5 14
      Libs/PluginFramework/ctkPluginDatabaseException.h

+ 8 - 25
Libs/PluginFramework/ctkPluginDatabaseException.cpp

@@ -24,47 +24,33 @@
 #include <QDebug>
 
 
-ctkPluginDatabaseException::ctkPluginDatabaseException(const QString& msg, const Type& type, const std::exception& cause)
-  : std::runtime_error(msg.toStdString()),
-    type(type), cause(cause)
+ctkPluginDatabaseException::ctkPluginDatabaseException(const QString& msg, const Type& type, const std::exception* cause)
+  : ctkRuntimeException(msg, cause),
+    type(type)
 {
 
 }
 
-ctkPluginDatabaseException::ctkPluginDatabaseException(const QString& msg, const std::exception& cause)
-  : std::runtime_error(msg.toStdString()),
-    type(UNSPECIFIED), cause(cause)
+ctkPluginDatabaseException::ctkPluginDatabaseException(const QString& msg, const std::exception* cause)
+  : ctkRuntimeException(msg, cause),
+    type(UNSPECIFIED)
 {
 
 }
 
 ctkPluginDatabaseException::ctkPluginDatabaseException(const ctkPluginDatabaseException& o)
-  : std::runtime_error(o.what()),
-    type(o.type), cause(o.cause)
+  : ctkRuntimeException(o), type(o.type)
 {
 
 }
 
 ctkPluginDatabaseException& ctkPluginDatabaseException::operator=(const ctkPluginDatabaseException& o)
 {
-  std::runtime_error::operator=(o);
+  ctkRuntimeException::operator=(o);
   type = o.type;
-  cause = o.cause;
   return *this;
 }
 
-std::exception ctkPluginDatabaseException::getCause() const
-{
-  return cause;
-}
-
-void ctkPluginDatabaseException::setCause(const std::exception& cause) throw(std::logic_error)
-{
-  if (!cause.what()) throw std::logic_error("The cause for this ctkPluginDatabaseException instance is already set");
-
-  this->cause = cause;
-}
-
 ctkPluginDatabaseException::Type ctkPluginDatabaseException::getType() const
 {
   return type;
@@ -75,9 +61,6 @@ QDebug operator<<(QDebug dbg, const ctkPluginDatabaseException& exc)
 {
   dbg << "ctkPluginDatabaseException:" << exc.what();
 
-  const char* causeMsg = exc.getCause().what();
-  if (causeMsg) dbg << "  Caused by:" << causeMsg;
-
   return dbg.maybeSpace();
 }
 

+ 5 - 14
Libs/PluginFramework/ctkPluginDatabaseException.h

@@ -22,14 +22,10 @@
 #ifndef CTKPLUGINDATABASEEXCEPTION_H
 #define CTKPLUGINDATABASEEXCEPTION_H
 
-#include "ctkPluginFrameworkExport.h"
+#include "ctkRuntimeException.h"
 
-#include <stdexcept>
 
-#include <QString>
-
-
-class CTK_PLUGINFW_EXPORT ctkPluginDatabaseException : public std::runtime_error
+class Q_DECL_EXPORT ctkPluginDatabaseException : public ctkRuntimeException
 {
 public:
 
@@ -44,23 +40,18 @@ public:
     DB_SQL_ERROR
   };
 
-  ctkPluginDatabaseException(const QString& msg, const Type& type = UNSPECIFIED, const std::exception& cause = std::exception());
-  ctkPluginDatabaseException(const QString& msg, const std::exception& cause);
+  ctkPluginDatabaseException(const QString& msg, const Type& type = UNSPECIFIED, const std::exception* cause = 0);
+  ctkPluginDatabaseException(const QString& msg, const std::exception* cause);
 
   ctkPluginDatabaseException(const ctkPluginDatabaseException& o);
   ctkPluginDatabaseException& operator=(const ctkPluginDatabaseException& o);
 
-  ~ctkPluginDatabaseException() throw() {}
-
-  std::exception getCause() const;
-  void setCause(const std::exception&) throw(std::logic_error);
   Type getType() const;
 
-
 private:
 
   Type type;
-  std::exception cause;
+
 };