diff SqliteDBLink.cpp @ 31:bf3dce7fedcb

Remove all references to QDebug
author Tom Fredrik Blenning Klaussen <bfg@blenning.no>
date Thu, 06 Sep 2012 19:14:58 +0200
parents 06166d6c083b
children c978d4a6514d
line wrap: on
line diff
--- a/SqliteDBLink.cpp	Thu Sep 06 18:39:01 2012 +0200
+++ b/SqliteDBLink.cpp	Thu Sep 06 19:14:58 2012 +0200
@@ -1,12 +1,15 @@
 #include "SqliteDBLink.hpp"
 
 #include <QtCore/QStringList>
-#include <QtCore/QDebug>
+#include <QtCore/QVariant>
+
 
 #include <QtSql/QSqlQuery>
 #include <QtSql/QSqlError>
 #include <QtSql/QSqlRecord>
 
+#include "Exception/SQLException.hpp"
+
 #include <cassert>
 
 SqliteDBLink::SqliteDBLink(const QString& dbPath)
@@ -20,8 +23,7 @@
     query.exec("CREATE TABLE files(path VARCHAR PRIMARY KEY ASC, size INTEGER, mtime TEXT, checksum TEXT);");
   }
   if (!query.exec(QString("SELECT * FROM files;"))) {
-    qDebug()<<"No database";
-    exit(1);
+    throw SQLException("No database");
   }
 
 }
@@ -37,7 +39,7 @@
   query.prepare("SELECT path FROM files WHERE path = :path;");
   query.bindValue(":path", path);
   if (!query.exec()) {
-    qDebug() << path << "::" << query.lastQuery() << "::" << query.lastError().text();
+    throw SQLException(query);
   }
   return query.last();
 }
@@ -48,7 +50,7 @@
   query.prepare("SELECT mtime FROM files WHERE path = :path;");
   query.bindValue(":path", path);
   if (!query.exec()) {
-    qDebug() << path << "::" << query.lastQuery() << "::" << query.lastError().text();
+    throw SQLException(query);
   }
   if (query.next()) {
     int dateIndex = query.record().indexOf("mtime");
@@ -77,7 +79,7 @@
   query.bindValue(":mtime", dbinfo.mtime());
   query.bindValue(":checksum", dbinfo.checksum());
   if (!query.exec()) {
-    qDebug() << dbinfo.path() << "::" << query.lastQuery() << "::" << query.lastError().text();
+    throw SQLException(query);
   }
   return true;
 }
@@ -96,7 +98,7 @@
   query.bindValue(":mtime", dbinfo.mtime());
   query.bindValue(":checksum", dbinfo.checksum());
   if (!query.exec()) {
-    qDebug() << query.lastError().text();
+    throw SQLException(query);
   }
 }
 
@@ -135,8 +137,7 @@
   }
 
   if (!query.exec()) {
-    qDebug() << prefix << "::" << query.lastQuery() << "::" << query.lastError().text();
-    abort();
+    throw SQLException(query);
   }
 
   int pathIndex = query.record().indexOf("path");
@@ -162,7 +163,7 @@
   query.prepare("DELETE FROM files WHERE path = :path");
   query.bindValue(":path", path);
   if (!query.exec()) {
-    qDebug() << path << "::" << query.lastQuery() << "::" << query.lastError().text();
+    throw SQLException(query);
   }
 }