From 6b9a3a534071ef84c121c406559f8fc7ad546104 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Fri, 11 Dec 2015 09:42:06 -0500 Subject: Reroot the exception hierarchy into a toplevel Exception class As the alternatives are unfortunate for applications trying to catch all library errors, and it seems deriving from std::runtime_error causes problems with MSVC DLLs (GH #340) Effectively reverts 2837e915d82e43 --- src/lib/utils/sqlite3/sqlite3.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/lib/utils/sqlite3') diff --git a/src/lib/utils/sqlite3/sqlite3.cpp b/src/lib/utils/sqlite3/sqlite3.cpp index 267d7530a..fde89b91d 100644 --- a/src/lib/utils/sqlite3/sqlite3.cpp +++ b/src/lib/utils/sqlite3/sqlite3.cpp @@ -20,7 +20,7 @@ Sqlite3_Database::Sqlite3_Database(const std::string& db_filename) const std::string err_msg = ::sqlite3_errmsg(m_db); ::sqlite3_close(m_db); m_db = nullptr; - throw std::runtime_error("sqlite3_open failed - " + err_msg); + throw Exception("sqlite3_open failed - " + err_msg); } } @@ -43,7 +43,7 @@ size_t Sqlite3_Database::row_count(const std::string& table_name) if(stmt->step()) return stmt->get_size_t(0); else - throw std::runtime_error("Querying size of table " + table_name + " failed"); + throw Exception("Querying size of table " + table_name + " failed"); } void Sqlite3_Database::create_table(const std::string& table_schema) @@ -57,7 +57,7 @@ void Sqlite3_Database::create_table(const std::string& table_schema) ::sqlite3_free(errmsg); ::sqlite3_close(m_db); m_db = nullptr; - throw std::runtime_error("sqlite3_exec for table failed - " + err_msg); + throw Exception("sqlite3_exec for table failed - " + err_msg); } } @@ -66,7 +66,7 @@ Sqlite3_Database::Sqlite3_Statement::Sqlite3_Statement(sqlite3* db, const std::s int rc = ::sqlite3_prepare_v2(db, base_sql.c_str(), -1, &m_stmt, nullptr); if(rc != SQLITE_OK) - throw std::runtime_error("sqlite3_prepare failed " + base_sql + + throw Exception("sqlite3_prepare failed " + base_sql + ", code " + std::to_string(rc)); } @@ -74,16 +74,16 @@ void Sqlite3_Database::Sqlite3_Statement::bind(int column, const std::string& va { int rc = ::sqlite3_bind_text(m_stmt, column, val.c_str(), -1, SQLITE_TRANSIENT); if(rc != SQLITE_OK) - throw std::runtime_error("sqlite3_bind_text failed, code " + std::to_string(rc)); + throw Exception("sqlite3_bind_text failed, code " + std::to_string(rc)); } void Sqlite3_Database::Sqlite3_Statement::bind(int column, size_t val) { if(val != static_cast(static_cast(val))) // is this legit? - throw std::runtime_error("sqlite3 cannot store " + std::to_string(val) + " without truncation"); + throw Exception("sqlite3 cannot store " + std::to_string(val) + " without truncation"); int rc = ::sqlite3_bind_int(m_stmt, column, val); if(rc != SQLITE_OK) - throw std::runtime_error("sqlite3_bind_int failed, code " + std::to_string(rc)); + throw Exception("sqlite3_bind_int failed, code " + std::to_string(rc)); } void Sqlite3_Database::Sqlite3_Statement::bind(int column, std::chrono::system_clock::time_point time) @@ -96,7 +96,7 @@ void Sqlite3_Database::Sqlite3_Statement::bind(int column, const std::vector Sqlite3_Database::Sqlite3_Statement::get_blob(int column) -- cgit v1.2.3