mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 17:56:13 -04:00
Renamed errmsg() and getErrStr() methods to getErrorMsg() and getErrorStr()
This commit is contained in:
parent
91abc3cb44
commit
401b7361ed
@ -266,8 +266,7 @@ public:
|
|||||||
/// Return the extended numeric result code for the most recent failed API call (if any).
|
/// Return the extended numeric result code for the most recent failed API call (if any).
|
||||||
int getExtendedErrorCode() const noexcept; // nothrow
|
int getExtendedErrorCode() const noexcept; // nothrow
|
||||||
/// Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
|
/// Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
|
||||||
// TODO: rename getErrorMessage
|
const char* getErrorMsg() const noexcept; // nothrow
|
||||||
const char* errmsg() const noexcept; // nothrow
|
|
||||||
|
|
||||||
/// Return the filename used to open the database.
|
/// Return the filename used to open the database.
|
||||||
const std::string& getFilename() const noexcept // nothrow
|
const std::string& getFilename() const noexcept // nothrow
|
||||||
@ -345,7 +344,6 @@ public:
|
|||||||
apApp, apFunc, apStep, apFinal, apDestroy);
|
apApp, apFunc, apStep, apFinal, apDestroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Load a module into the current sqlite database instance.
|
* @brief Load a module into the current sqlite database instance.
|
||||||
*
|
*
|
||||||
@ -361,8 +359,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @throw SQLite::Exception in case of error
|
* @throw SQLite::Exception in case of error
|
||||||
*/
|
*/
|
||||||
void loadExtension(const char* apExtensionName,
|
void loadExtension(const char* apExtensionName, const char* apEntryPointName);
|
||||||
const char *apEntryPointName);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @{ Database must be non-copyable
|
/// @{ Database must be non-copyable
|
||||||
|
@ -79,10 +79,10 @@ public:
|
|||||||
int getErrorCode() const noexcept; // nothrow
|
int getErrorCode() const noexcept; // nothrow
|
||||||
|
|
||||||
/// Return the extended numeric result code (if any, otherwise -1).
|
/// 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
|
/// Return a string, solely based on the error code
|
||||||
inline const char *getErrStr() const noexcept; // nothrow
|
const char* getErrorStr() const noexcept; // nothrow
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int mErrcode; ///< Error code value
|
const int mErrcode; ///< Error code value
|
||||||
|
@ -487,7 +487,7 @@ public:
|
|||||||
/// Return the extended numeric result code for the most recent failed API call (if any).
|
/// Return the extended numeric result code for the most recent failed API call (if any).
|
||||||
int getExtendedErrorCode() const noexcept; // nothrow
|
int getExtendedErrorCode() const noexcept; // nothrow
|
||||||
/// Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
|
/// 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:
|
private:
|
||||||
/**
|
/**
|
||||||
|
@ -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).
|
// 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);
|
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.
|
// 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
|
// Parameter details can be found here: http://www.sqlite.org/c3ref/load_extension.html
|
||||||
void Database::loadExtension(const char* apExtensionName,
|
void Database::loadExtension(const char* apExtensionName, const char *apEntryPointName)
|
||||||
const char *apEntryPointName)
|
|
||||||
{
|
{
|
||||||
#ifdef SQLITE_OMIT_LOAD_EXTENSION
|
#ifdef SQLITE_OMIT_LOAD_EXTENSION
|
||||||
throw std::runtime_error("sqlite extensions are disabled");
|
throw std::runtime_error("sqlite extensions are disabled");
|
||||||
|
@ -57,7 +57,7 @@ inline int Exception::getExtendedErrorCode() const noexcept // nothrow
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return a string, solely based on the error code
|
// 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);
|
return sqlite3_errstr(mErrcode);
|
||||||
}
|
}
|
||||||
|
@ -370,7 +370,7 @@ int Statement::getExtendedErrorCode() const noexcept // nothrow
|
|||||||
return sqlite3_extended_errcode(mStmtPtr);
|
return sqlite3_extended_errcode(mStmtPtr);
|
||||||
}
|
}
|
||||||
/// Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
|
/// 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);
|
return sqlite3_errmsg(mStmtPtr);
|
||||||
}
|
}
|
||||||
|
@ -222,19 +222,19 @@ TEST(Database, execException) {
|
|||||||
EXPECT_THROW(db.exec("INSERT INTO test VALUES (NULL, \"first\", 3)"), SQLite::Exception);
|
EXPECT_THROW(db.exec("INSERT INTO test VALUES (NULL, \"first\", 3)"), SQLite::Exception);
|
||||||
EXPECT_EQ(SQLITE_ERROR, db.getErrorCode());
|
EXPECT_EQ(SQLITE_ERROR, db.getErrorCode());
|
||||||
EXPECT_EQ(SQLITE_ERROR, db.getExtendedErrorCode());
|
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
|
// Create a new table
|
||||||
db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT, weight INTEGER)");
|
db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT, weight INTEGER)");
|
||||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||||
EXPECT_EQ(SQLite::OK, db.getExtendedErrorCode());
|
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"
|
// 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_THROW(db.exec("INSERT INTO test VALUES (NULL, 3)"), SQLite::Exception);
|
||||||
EXPECT_EQ(SQLITE_ERROR, db.getErrorCode());
|
EXPECT_EQ(SQLITE_ERROR, db.getErrorCode());
|
||||||
EXPECT_EQ(SQLITE_ERROR, db.getExtendedErrorCode());
|
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"
|
// exception with SQL error: "No row to get a column from"
|
||||||
EXPECT_THROW(db.execAndGet("SELECT weight FROM test WHERE value=\"first\""), SQLite::Exception);
|
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_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.getErrorCode());
|
||||||
EXPECT_EQ(SQLITE_ERROR, db.getExtendedErrorCode());
|
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()
|
// TODO: test Database::createFunction()
|
||||||
|
@ -71,10 +71,10 @@ TEST(Statement, invalid) {
|
|||||||
EXPECT_THROW(query.bind(0), SQLite::Exception);
|
EXPECT_THROW(query.bind(0), SQLite::Exception);
|
||||||
EXPECT_EQ(SQLITE_RANGE, db.getErrorCode());
|
EXPECT_EQ(SQLITE_RANGE, db.getErrorCode());
|
||||||
EXPECT_EQ(SQLITE_RANGE, db.getExtendedErrorCode());
|
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.getErrorCode());
|
||||||
EXPECT_EQ(SQLITE_RANGE, query.getExtendedErrorCode());
|
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
|
query.exec(); // exec() instead of executeStep() as there is no result
|
||||||
EXPECT_THROW(query.isColumnNull(0), SQLite::Exception);
|
EXPECT_THROW(query.isColumnNull(0), SQLite::Exception);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user