From 401b7361ed7b7cfa8b02b86a9a280d5210bac762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rombauts?= Date: Wed, 13 Jul 2016 18:37:22 +0200 Subject: [PATCH] Renamed errmsg() and getErrStr() methods to getErrorMsg() and getErrorStr() --- include/SQLiteCpp/Database.h | 7 ++----- include/SQLiteCpp/Exception.h | 4 ++-- include/SQLiteCpp/Statement.h | 2 +- src/Database.cpp | 5 ++--- src/Exception.cpp | 2 +- src/Statement.cpp | 2 +- tests/Database_test.cpp | 8 ++++---- tests/Statement_test.cpp | 4 ++-- 8 files changed, 15 insertions(+), 19 deletions(-) diff --git a/include/SQLiteCpp/Database.h b/include/SQLiteCpp/Database.h index 1ab2e24..352aa5e 100644 --- a/include/SQLiteCpp/Database.h +++ b/include/SQLiteCpp/Database.h @@ -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 diff --git a/include/SQLiteCpp/Exception.h b/include/SQLiteCpp/Exception.h index 32bfe46..07f296b 100644 --- a/include/SQLiteCpp/Exception.h +++ b/include/SQLiteCpp/Exception.h @@ -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 diff --git a/include/SQLiteCpp/Statement.h b/include/SQLiteCpp/Statement.h index db7f695..2072161 100644 --- a/include/SQLiteCpp/Statement.h +++ b/include/SQLiteCpp/Statement.h @@ -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: /** diff --git a/src/Database.cpp b/src/Database.cpp index 185a872..0ef9145 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -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"); diff --git a/src/Exception.cpp b/src/Exception.cpp index 9e356c0..45bbe0d 100644 --- a/src/Exception.cpp +++ b/src/Exception.cpp @@ -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); } diff --git a/src/Statement.cpp b/src/Statement.cpp index 9c7441e..28ae75d 100644 --- a/src/Statement.cpp +++ b/src/Statement.cpp @@ -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); } diff --git a/tests/Database_test.cpp b/tests/Database_test.cpp index bcb91ed..83c3750 100644 --- a/tests/Database_test.cpp +++ b/tests/Database_test.cpp @@ -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() diff --git a/tests/Statement_test.cpp b/tests/Statement_test.cpp index 0237027..89bc1fb 100644 --- a/tests/Statement_test.cpp +++ b/tests/Statement_test.cpp @@ -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);