Renamed errmsg() and getErrStr() methods to getErrorMsg() and getErrorStr()

This commit is contained in:
Sébastien Rombauts 2016-07-13 18:37:22 +02:00
parent 91abc3cb44
commit 401b7361ed
8 changed files with 15 additions and 19 deletions

View File

@ -266,8 +266,7 @@ public:
/// Return the extended numeric result code for the most recent failed API call (if any).
int getExtendedErrorCode() const noexcept; // nothrow
/// Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
// TODO: rename getErrorMessage
const char* errmsg() const noexcept; // nothrow
const char* getErrorMsg() const noexcept; // nothrow
/// Return the filename used to open the database.
const std::string& getFilename() const noexcept // nothrow
@ -345,7 +344,6 @@ public:
apApp, apFunc, apStep, apFinal, apDestroy);
}
/**
* @brief Load a module into the current sqlite database instance.
*
@ -361,8 +359,7 @@ public:
*
* @throw SQLite::Exception in case of error
*/
void loadExtension(const char* apExtensionName,
const char *apEntryPointName);
void loadExtension(const char* apExtensionName, const char* apEntryPointName);
private:
/// @{ Database must be non-copyable

View File

@ -79,10 +79,10 @@ public:
int getErrorCode() const noexcept; // nothrow
/// Return the extended numeric result code (if any, otherwise -1).
inline int getExtendedErrorCode() const noexcept; // nothrow
int getExtendedErrorCode() const noexcept; // nothrow
/// Return a string, solely based on the error code
inline const char *getErrStr() const noexcept; // nothrow
const char* getErrorStr() const noexcept; // nothrow
private:
const int mErrcode; ///< Error code value

View File

@ -487,7 +487,7 @@ public:
/// Return the extended numeric result code for the most recent failed API call (if any).
int getExtendedErrorCode() const noexcept; // nothrow
/// Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
const char* errmsg() const noexcept; // nothrow
const char* getErrorMsg() const noexcept; // nothrow
private:
/**

View File

@ -166,7 +166,7 @@ int Database::getExtendedErrorCode() const noexcept // nothrow
}
// Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
const char* Database::errmsg() const noexcept // nothrow
const char* Database::getErrorMsg() const noexcept // nothrow
{
return sqlite3_errmsg(mpSQLite);
}
@ -194,8 +194,7 @@ void Database::createFunction(const char* apFuncName,
// Load an extension into the sqlite database. Only affects the current connection.
// Parameter details can be found here: http://www.sqlite.org/c3ref/load_extension.html
void Database::loadExtension(const char* apExtensionName,
const char *apEntryPointName)
void Database::loadExtension(const char* apExtensionName, const char *apEntryPointName)
{
#ifdef SQLITE_OMIT_LOAD_EXTENSION
throw std::runtime_error("sqlite extensions are disabled");

View File

@ -57,7 +57,7 @@ inline int Exception::getExtendedErrorCode() const noexcept // nothrow
}
// Return a string, solely based on the error code
inline const char *Exception::getErrStr() const noexcept // nothrow
inline const char* Exception::getErrorStr() const noexcept // nothrow
{
return sqlite3_errstr(mErrcode);
}

View File

@ -370,7 +370,7 @@ int Statement::getExtendedErrorCode() const noexcept // nothrow
return sqlite3_extended_errcode(mStmtPtr);
}
/// Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
const char* Statement::errmsg() const noexcept // nothrow
const char* Statement::getErrorMsg() const noexcept // nothrow
{
return sqlite3_errmsg(mStmtPtr);
}

View File

@ -222,19 +222,19 @@ TEST(Database, execException) {
EXPECT_THROW(db.exec("INSERT INTO test VALUES (NULL, \"first\", 3)"), SQLite::Exception);
EXPECT_EQ(SQLITE_ERROR, db.getErrorCode());
EXPECT_EQ(SQLITE_ERROR, db.getExtendedErrorCode());
EXPECT_STREQ("no such table: test", db.errmsg());
EXPECT_STREQ("no such table: test", db.getErrorMsg());
// Create a new table
db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT, weight INTEGER)");
EXPECT_EQ(SQLite::OK, db.getErrorCode());
EXPECT_EQ(SQLite::OK, db.getExtendedErrorCode());
EXPECT_STREQ("not an error", db.errmsg());
EXPECT_STREQ("not an error", db.getErrorMsg());
// exception with SQL error: "table test has 3 columns but 2 values were supplied"
EXPECT_THROW(db.exec("INSERT INTO test VALUES (NULL, 3)"), SQLite::Exception);
EXPECT_EQ(SQLITE_ERROR, db.getErrorCode());
EXPECT_EQ(SQLITE_ERROR, db.getExtendedErrorCode());
EXPECT_STREQ("table test has 3 columns but 2 values were supplied", db.errmsg());
EXPECT_STREQ("table test has 3 columns but 2 values were supplied", db.getErrorMsg());
// exception with SQL error: "No row to get a column from"
EXPECT_THROW(db.execAndGet("SELECT weight FROM test WHERE value=\"first\""), SQLite::Exception);
@ -247,7 +247,7 @@ TEST(Database, execException) {
EXPECT_THROW(db.exec("INSERT INTO test VALUES (NULL, \"first\", 123, 0.123)"), SQLite::Exception);
EXPECT_EQ(SQLITE_ERROR, db.getErrorCode());
EXPECT_EQ(SQLITE_ERROR, db.getExtendedErrorCode());
EXPECT_STREQ("table test has 3 columns but 4 values were supplied", db.errmsg());
EXPECT_STREQ("table test has 3 columns but 4 values were supplied", db.getErrorMsg());
}
// TODO: test Database::createFunction()

View File

@ -71,10 +71,10 @@ TEST(Statement, invalid) {
EXPECT_THROW(query.bind(0), SQLite::Exception);
EXPECT_EQ(SQLITE_RANGE, db.getErrorCode());
EXPECT_EQ(SQLITE_RANGE, db.getExtendedErrorCode());
EXPECT_STREQ("bind or column index out of range", db.errmsg());
EXPECT_STREQ("bind or column index out of range", db.getErrorMsg());
EXPECT_EQ(SQLITE_RANGE, query.getErrorCode());
EXPECT_EQ(SQLITE_RANGE, query.getExtendedErrorCode());
EXPECT_STREQ("bind or column index out of range", query.errmsg());
EXPECT_STREQ("bind or column index out of range", query.getErrorMsg());
query.exec(); // exec() instead of executeStep() as there is no result
EXPECT_THROW(query.isColumnNull(0), SQLite::Exception);