Database error handling.

This commit is contained in:
2016-02-13 21:41:05 +01:00
parent 3d9e182531
commit 1f4f318a26
15 changed files with 171 additions and 29 deletions
+14
View File
@@ -67,6 +67,7 @@ public:
catch (const odb::exception &ex)
{
emit dbError(ex.what());
emit dbErrorUpdate(ex.what());
return;
}
@@ -88,6 +89,8 @@ public:
catch (const odb::exception &ex)
{
emit dbError(ex.what());
emit dbErrorInsert(ex.what());
return;
}
emit dataChanged();
@@ -109,11 +112,21 @@ public:
catch (const odb::exception &ex)
{
emit dbError(ex.what());
emit dbErrorRead(ex.what());
}
return entity;
}
QSharedPointer<T> reload(int id) {
odb::database *db = Context::instance().db();
Q_ASSERT(db);
Context::instance().session().cache_erase<T>(*db, id);
return loadById(id);
}
void erase(QSharedPointer<T> entity) {
odb::database *db = Context::instance().db();
@@ -129,6 +142,7 @@ public:
catch (const odb::exception &ex)
{
emit dbError(ex.what());
emit dbErrorDelete(ex.what());
}
}