Mercurial > dedupe
comparison DBCache.hpp @ 32:c978d4a6514d
Replace unnecessary asserts with exceptions.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Thu, 06 Sep 2012 19:22:32 +0200 |
| parents | bf3dce7fedcb |
| children | fda70a362ed5 |
comparison
equal
deleted
inserted
replaced
| 31:bf3dce7fedcb | 32:c978d4a6514d |
|---|---|
| 7 #include <QtSql/QSqlRecord> | 7 #include <QtSql/QSqlRecord> |
| 8 | 8 |
| 9 | 9 |
| 10 #include <QtCore/QStringList> | 10 #include <QtCore/QStringList> |
| 11 #include <QtCore/QVariant> | 11 #include <QtCore/QVariant> |
| 12 #include <cassert> | |
| 13 #include "OrderedPair.hpp" | 12 #include "OrderedPair.hpp" |
| 14 | 13 |
| 15 #include <boost/optional.hpp> | 14 #include <boost/optional.hpp> |
| 16 | 15 |
| 17 #include "ThreadSafeLookup.hpp" | 16 #include "ThreadSafeLookup.hpp" |
| 18 #include "UniqueString.hpp" | 17 #include "UniqueString.hpp" |
| 19 #include "Exception/SQLException.hpp" | 18 #include "Exception/SQLException.hpp" |
| 19 #include "Exception/IOException.hpp" | |
| 20 | 20 |
| 21 | 21 |
| 22 template<typename T> | 22 template<typename T> |
| 23 struct SQLGenerator | 23 struct SQLGenerator |
| 24 { | 24 { |
| 299 public: | 299 public: |
| 300 DBCache(const QString& dbName, const QString& dictName) | 300 DBCache(const QString& dbName, const QString& dictName) |
| 301 { | 301 { |
| 302 db = QSqlDatabase::addDatabase("QSQLITE", "dictName"); | 302 db = QSqlDatabase::addDatabase("QSQLITE", "dictName"); |
| 303 db.setDatabaseName(dbName); | 303 db.setDatabaseName(dbName); |
| 304 bool ok = db.open(); | 304 if (!db.open()) |
| 305 assert(ok); | 305 throw IOException(QString("Unable to open SQLite database with path '%1'").arg(dictName)); |
| 306 setup(db, dictName); | 306 setup(db, dictName); |
| 307 } | 307 } |
| 308 | 308 |
| 309 DBCache(const QSqlDatabase& db, const QString& dictName) | 309 DBCache(const QSqlDatabase& db, const QString& dictName) |
| 310 { | 310 { |
