Cleanup post merge request #84 : one more exception constructor

This commit is contained in:
Sébastien Rombauts 2016-06-27 08:54:32 +02:00
parent bd6c13c6ca
commit 90699f95ea
2 changed files with 24 additions and 16 deletions

View File

@ -57,6 +57,18 @@ public:
{ {
} }
/**
* @brief Encapsulation of the error message from SQLite3, based on std::runtime_error.
*
* @param[in] aErrorMessage The string message describing the SQLite error
*/
explicit Exception(const std::string& aErrorMessage, int ret) :
std::runtime_error(aErrorMessage),
mErrcode(ret),
mExtendedErrcode(-1)
{
}
/** /**
* @brief Encapsulation of the error message from SQLite3, based on std::runtime_error. * @brief Encapsulation of the error message from SQLite3, based on std::runtime_error.
* *

View File

@ -48,8 +48,7 @@ Backup::Backup(Database &aDestDatabase,
aSrcDatabaseName.c_str()); aSrcDatabaseName.c_str());
if (NULL == mpSQLiteBackup) if (NULL == mpSQLiteBackup)
{ {
std::string strerr = sqlite3_errmsg(aDestDatabase.getHandle()); throw SQLite::Exception(aDestDatabase.getHandle());
throw SQLite::Exception(strerr);
} }
} }
@ -63,8 +62,7 @@ Backup::Backup(Database &aDestDatabase, Database &aSrcDatabase) :
"main"); "main");
if (NULL == mpSQLiteBackup) if (NULL == mpSQLiteBackup)
{ {
std::string strerr = sqlite3_errmsg(aDestDatabase.getHandle()); throw SQLite::Exception(aDestDatabase.getHandle());
throw SQLite::Exception(strerr);
} }
} }
@ -81,11 +79,9 @@ Backup::~Backup() noexcept
int Backup::executeStep(const int aNumPage /* = -1 */) int Backup::executeStep(const int aNumPage /* = -1 */)
{ {
const int res = sqlite3_backup_step(mpSQLiteBackup, aNumPage); const int res = sqlite3_backup_step(mpSQLiteBackup, aNumPage);
if (SQLITE_OK != res && SQLITE_DONE != res && if (SQLITE_OK != res && SQLITE_DONE != res && SQLITE_BUSY != res && SQLITE_LOCKED != res)
SQLITE_BUSY != res && SQLITE_LOCKED != res)
{ {
std::string strerr = sqlite3_errstr(res); throw SQLite::Exception(sqlite3_errstr(res), res);
throw SQLite::Exception(strerr);
} }
return res; return res;
} }