mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-05 10:16:01 -04:00
Cleanup post merge request #84 : one more exception constructor
This commit is contained in:
parent
bd6c13c6ca
commit
90699f95ea
@ -58,6 +58,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.
|
||||||
*
|
*
|
||||||
* @param[in] apSQLite The SQLite object, to obtain detailed error messages from.
|
* @param[in] apSQLite The SQLite object, to obtain detailed error messages from.
|
||||||
|
@ -19,10 +19,10 @@ namespace SQLite
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Initialize resource for SQLite database backup
|
// Initialize resource for SQLite database backup
|
||||||
Backup::Backup(Database& aDestDatabase,
|
Backup::Backup(Database& aDestDatabase,
|
||||||
const char *apDestDatabaseName,
|
const char* apDestDatabaseName,
|
||||||
Database& aSrcDatabase,
|
Database& aSrcDatabase,
|
||||||
const char *apSrcDatabaseName) :
|
const char* apSrcDatabaseName) :
|
||||||
mpSQLiteBackup(NULL)
|
mpSQLiteBackup(NULL)
|
||||||
{
|
{
|
||||||
mpSQLiteBackup = sqlite3_backup_init(aDestDatabase.getHandle(),
|
mpSQLiteBackup = sqlite3_backup_init(aDestDatabase.getHandle(),
|
||||||
@ -36,10 +36,10 @@ Backup::Backup(Database& aDestDatabase,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize resource for SQLite database backup
|
// Initialize resource for SQLite database backup
|
||||||
Backup::Backup(Database &aDestDatabase,
|
Backup::Backup(Database& aDestDatabase,
|
||||||
const std::string &aDestDatabaseName,
|
const std::string& aDestDatabaseName,
|
||||||
Database &aSrcDatabase,
|
Database& aSrcDatabase,
|
||||||
const std::string &aSrcDatabaseName) :
|
const std::string& aSrcDatabaseName) :
|
||||||
mpSQLiteBackup(NULL)
|
mpSQLiteBackup(NULL)
|
||||||
{
|
{
|
||||||
mpSQLiteBackup = sqlite3_backup_init(aDestDatabase.getHandle(),
|
mpSQLiteBackup = sqlite3_backup_init(aDestDatabase.getHandle(),
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user