# HG changeset patch # User Tom Fredrik Blenning Klaussen # Date 1346951698 -7200 # Node ID bf3dce7fedcbc55f08b52c3452c0f1dc1a364301 # Parent 1072257d2babf6edebdac8b9c85619f444c49084 Remove all references to QDebug diff -r 1072257d2bab -r bf3dce7fedcb CMakeLists.txt --- a/CMakeLists.txt Thu Sep 06 18:39:01 2012 +0200 +++ b/CMakeLists.txt Thu Sep 06 19:14:58 2012 +0200 @@ -32,6 +32,7 @@ HuffmanSet.cpp EditDistance.cpp Exception/IOException.cpp + Exception/SQLException.cpp FileDBLink.cpp SqliteDBLink.cpp MemoryDBLink.cpp @@ -85,8 +86,7 @@ ADD_TEST(TestEditDistance TestEditDistance) TARGET_LINK_LIBRARIES(TestEditDistance ${QT_LIBRARIES} ${Boost_LIBRARIES}) -#ADD_EXECUTABLE(TestDBCache TestDBCache.cpp ${TEST_SOURCES}) -ADD_EXECUTABLE(TestDBCache TestDBCache.cpp) +ADD_EXECUTABLE(TestDBCache TestDBCache.cpp ${TEST_SOURCES}) ADD_TEST(TestDBCache TestDBCache) TARGET_LINK_LIBRARIES(TestDBCache ${QT_LIBRARIES} ${Boost_LIBRARIES}) diff -r 1072257d2bab -r bf3dce7fedcb DBCache.hpp --- a/DBCache.hpp Thu Sep 06 18:39:01 2012 +0200 +++ b/DBCache.hpp Thu Sep 06 19:14:58 2012 +0200 @@ -6,8 +6,9 @@ #include #include -#include + #include +#include #include #include "OrderedPair.hpp" @@ -15,6 +16,7 @@ #include "ThreadSafeLookup.hpp" #include "UniqueString.hpp" +#include "Exception/SQLException.hpp" template @@ -253,8 +255,7 @@ query.exec(createQuery); } if (!db.tables().contains(dictName)) { - qDebug()<<"No database"; - exit(1); + throw SQLException("No databaase"); } if (memoryMapped) { QString keyFields = SQLGenerator::fieldName("key"); @@ -262,7 +263,7 @@ QString repopulateQuery = QString("SELECT %1, %2 FROM %3;").arg(keyFields).arg(valueFields).arg(dictName); QSqlQuery query(db); if (!query.exec(repopulateQuery)) { - qDebug() << query.lastError() << repopulateQuery; + throw SQLException(query); } while (query.next()) { Key key = *SQLGenerator::extract(query, "key"); @@ -289,7 +290,7 @@ } SQLGenerator::bindValues(insertQuery, values, "value"); if (!insertQuery.exec()) { - qDebug() << insertQuery.lastError() << insertQuery.lastQuery(); + throw SQLException(insertQuery); } insertQuery.finish(); unsyncedKeys.clear(); @@ -324,7 +325,7 @@ query.prepare(queryString); SQLGenerator::bindValue(query, key, "key"); if (!query.exec()) { - qDebug() << query.lastError() << queryString; + throw SQLException(query); } query.next(); return SQLGenerator::extract(query, "value"); @@ -344,7 +345,7 @@ SQLGenerator::bindValue(insertQuery, key, "key"); SQLGenerator::bindValue(insertQuery, value, "value"); if (!insertQuery.exec()) { - qDebug() << insertQuery.lastError() << insertQuery.lastQuery(); + throw SQLException(insertQuery); } insertQuery.finish(); } diff -r 1072257d2bab -r bf3dce7fedcb DataController.cpp --- a/DataController.cpp Thu Sep 06 18:39:01 2012 +0200 +++ b/DataController.cpp Thu Sep 06 19:14:58 2012 +0200 @@ -8,7 +8,7 @@ #include #include -#include + #include #include #include diff -r 1072257d2bab -r bf3dce7fedcb Exception/SQLException.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Exception/SQLException.cpp Thu Sep 06 19:14:58 2012 +0200 @@ -0,0 +1,13 @@ +#include "SQLException.hpp" + +#include +#include + +SQLException::SQLException(const QString& errorMsg) : Exception(errorMsg) +{ +} + +SQLException::SQLException(const QSqlQuery& errorQuery) : + Exception(errorQuery.lastError().text() + ":" + errorQuery.lastQuery()) +{ +} diff -r 1072257d2bab -r bf3dce7fedcb Exception/SQLException.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Exception/SQLException.hpp Thu Sep 06 19:14:58 2012 +0200 @@ -0,0 +1,13 @@ +#ifndef SQLEXCEPTION_HPP +#define SQLEXCEPTION_HPP + +#include "Exception.hpp" +class QSqlQuery; + +class SQLException : public Exception { +public: + SQLException(const string_t& errMsg); + SQLException(const QSqlQuery& error); +}; + +#endif //IOEXCEPTION_HPP diff -r 1072257d2bab -r bf3dce7fedcb FileDBLink.cpp --- a/FileDBLink.cpp Thu Sep 06 18:39:01 2012 +0200 +++ b/FileDBLink.cpp Thu Sep 06 19:14:58 2012 +0200 @@ -2,7 +2,7 @@ #include "FileDBLink.hpp" #include "Exception/PermissionException.hpp" -#include + #include #include diff -r 1072257d2bab -r bf3dce7fedcb RBTree.hpp --- a/RBTree.hpp Thu Sep 06 18:39:01 2012 +0200 +++ b/RBTree.hpp Thu Sep 06 19:14:58 2012 +0200 @@ -5,7 +5,7 @@ #include #include "Exception/ValueExistsException.hpp" -#include + #define CONSISTENCY_CHECKING 1 diff -r 1072257d2bab -r bf3dce7fedcb SqliteDBLink.cpp --- 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 -#include +#include + #include #include #include +#include "Exception/SQLException.hpp" + #include 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); } } diff -r 1072257d2bab -r bf3dce7fedcb TestBitDecoder.cpp --- a/TestBitDecoder.cpp Thu Sep 06 18:39:01 2012 +0200 +++ b/TestBitDecoder.cpp Thu Sep 06 19:14:58 2012 +0200 @@ -2,7 +2,7 @@ #include "TestFramework.hpp" #include "Exception/InvalidDataException.hpp" -#include + QBitArray bitsFromString(const QString& str) { diff -r 1072257d2bab -r bf3dce7fedcb TestHuffmanString.cpp --- a/TestHuffmanString.cpp Thu Sep 06 18:39:01 2012 +0200 +++ b/TestHuffmanString.cpp Thu Sep 06 19:14:58 2012 +0200 @@ -1,7 +1,7 @@ #include "HuffmanString.hpp" #include "TestFramework.hpp" -#include + BOOST_AUTO_TEST_CASE( TestSimple ) { diff -r 1072257d2bab -r bf3dce7fedcb UniqueString.hpp --- a/UniqueString.hpp Thu Sep 06 18:39:01 2012 +0200 +++ b/UniqueString.hpp Thu Sep 06 19:14:58 2012 +0200 @@ -23,7 +23,7 @@ #include "RBTree.hpp" #include #include -#include + class UniqueString {