changeset 82:f507a7240bc9

Functionality for easy clearing of a query when throwing an exception.
author Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
date Thu, 10 Oct 2013 14:13:01 +0200
parents 69a30d9f126e
children c17475848bf4
files Exception/SQLException.cpp Exception/SQLException.hpp
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Exception/SQLException.cpp	Thu Oct 10 14:12:17 2013 +0200
+++ b/Exception/SQLException.cpp	Thu Oct 10 14:13:01 2013 +0200
@@ -12,6 +12,13 @@
 {
 }
 
+SQLException::SQLException(QSqlQuery& errorQuery, bool clear) :
+  Exception(errorQuery.lastError().text() + ":" + errorQuery.lastQuery())
+{
+  if (clear)
+    errorQuery.clear();
+}
+
 void SQLException::raise() const
 {
   throw *this;
--- a/Exception/SQLException.hpp	Thu Oct 10 14:12:17 2013 +0200
+++ b/Exception/SQLException.hpp	Thu Oct 10 14:13:01 2013 +0200
@@ -8,6 +8,7 @@
 public:
   SQLException(const string_t& errMsg);
   SQLException(const QSqlQuery& error);
+  SQLException(QSqlQuery& error, bool clear);
 
   virtual void raise() const;
 };