diff --git a/include/SQLiteCpp/Database.h b/include/SQLiteCpp/Database.h index 71ebc5b..7a2c186 100644 --- a/include/SQLiteCpp/Database.h +++ b/include/SQLiteCpp/Database.h @@ -378,7 +378,7 @@ private: { if (SQLITE_OK != aRet) { - throw SQLite::Exception(sqlite3_errmsg(mpSQLite)); + throw SQLite::Exception(sqlite3_errstr(aRet)); } } diff --git a/include/SQLiteCpp/Statement.h b/include/SQLiteCpp/Statement.h index fd08137..363e98c 100644 --- a/include/SQLiteCpp/Statement.h +++ b/include/SQLiteCpp/Statement.h @@ -457,7 +457,7 @@ private: { if (SQLITE_OK != aRet) { - throw SQLite::Exception(sqlite3_errmsg(mStmtPtr)); + throw SQLite::Exception(sqlite3_errstr(aRet)); } } diff --git a/src/Backup.cpp b/src/Backup.cpp index 504042f..ba8815a 100644 --- a/src/Backup.cpp +++ b/src/Backup.cpp @@ -85,11 +85,7 @@ int Backup::executeStep(const int aNumPage /* = -1 */) if (SQLITE_OK != res && SQLITE_DONE != res && SQLITE_BUSY != res && SQLITE_LOCKED != res) { - std::string strerr("Backup executeStep error"); -#if SQLITE_VERSION_NUMBER >= 3007015 // SQLite v3.7.15 is the first version with sqlite3_errstr() interface - strerr += "with error message "; - strerr += sqlite3_errstr(res); -#endif + std::string strerr = sqlite3_errstr(res); throw SQLite::Exception(strerr); } return res; diff --git a/src/Database.cpp b/src/Database.cpp index b9440ac..2ce2183 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -36,7 +36,7 @@ Database::Database(const char* apFilename, const int ret = sqlite3_open_v2(apFilename, &mpSQLite, aFlags, apVfs); if (SQLITE_OK != ret) { - std::string strerr = sqlite3_errmsg(mpSQLite); + std::string strerr = sqlite3_errstr(ret); sqlite3_close(mpSQLite); // close is required even in case of error on opening throw SQLite::Exception(strerr); } @@ -58,7 +58,7 @@ Database::Database(const std::string& aFilename, const int ret = sqlite3_open_v2(aFilename.c_str(), &mpSQLite, aFlags, aVfs.empty() ? NULL : aVfs.c_str()); if (SQLITE_OK != ret) { - std::string strerr = sqlite3_errmsg(mpSQLite); + std::string strerr = sqlite3_errstr(ret); sqlite3_close(mpSQLite); // close is required even in case of error on opening throw SQLite::Exception(strerr); } @@ -85,7 +85,7 @@ Database::~Database() noexcept // nothrow /** * @brief Set a busy handler that sleeps for a specified amount of time when a table is locked. * - * This is usefull in multithreaded program to handle case where a table is locked for writting by a thread. + * This is useful in multithreaded program to handle case where a table is locked for writting by a thread. * Any other thread cannot access the table and will receive a SQLITE_BUSY error: * setting a timeout will wait and retry up to the time specified before returning this SQLITE_BUSY error. * Reading the value of timeout for current connection can be done with SQL query "PRAGMA busy_timeout;". diff --git a/src/Statement.cpp b/src/Statement.cpp index 86e5919..519daf5 100644 --- a/src/Statement.cpp +++ b/src/Statement.cpp @@ -195,7 +195,7 @@ bool Statement::executeStep() { mbOk = false; mbDone = false; - throw SQLite::Exception(sqlite3_errmsg(mStmtPtr)); + throw SQLite::Exception(sqlite3_errstr(ret)); } } else @@ -227,7 +227,7 @@ int Statement::exec() { mbOk = false; mbDone = false; - throw SQLite::Exception(sqlite3_errmsg(mStmtPtr)); + throw SQLite::Exception(sqlite3_errstr(ret)); } } else @@ -317,7 +317,7 @@ Statement::Ptr::Ptr(sqlite3* apSQLite, std::string& aQuery) : const int ret = sqlite3_prepare_v2(apSQLite, aQuery.c_str(), static_cast(aQuery.size()), &mpStmt, NULL); if (SQLITE_OK != ret) { - throw SQLite::Exception(sqlite3_errmsg(mpSQLite)); + throw SQLite::Exception(sqlite3_errstr(ret)); } // Initialize the reference counter of the sqlite3_stmt : // used to share the mStmtPtr between Statement and Column objects;