diff --git a/catalogue/MysqlCatalogue.cpp b/catalogue/MysqlCatalogue.cpp index db7a4ecc1f02a0bf0c06504927240c0b5573e007..edd101bdd79f6041a2d2e37c66cceb6d07f94531 100644 --- a/catalogue/MysqlCatalogue.cpp +++ b/catalogue/MysqlCatalogue.cpp @@ -19,8 +19,6 @@ #include "catalogue/ArchiveFileRow.hpp" #include "catalogue/MysqlCatalogueSchema.hpp" #include "catalogue/MysqlCatalogue.hpp" -#include "common/exception/DatabaseConstraintError.hpp" -#include "common/exception/DatabasePrimaryKeyError.hpp" #include "common/exception/Exception.hpp" #include "common/exception/UserError.hpp" #include "common/make_unique.hpp" @@ -28,6 +26,8 @@ #include "common/Timer.hpp" #include "common/utils/utils.hpp" #include "rdbms/AutoRollback.hpp" +#include "rdbms/ConstraintError.hpp" +#include "rdbms/PrimaryKeyError.hpp" namespace cta { namespace catalogue { @@ -336,7 +336,7 @@ void MysqlCatalogue::fileWrittenToTape(rdbms::Conn &conn, const TapeFileWritten row.diskFileOwnerUid = event.diskFileOwnerUid; row.diskFileGid = event.diskFileGid; insertArchiveFile(conn, row); - } catch(exception::DatabasePrimaryKeyError &) { + } catch(rdbms::PrimaryKeyError &) { // Ignore this error } diff --git a/catalogue/SqliteCatalogue.cpp b/catalogue/SqliteCatalogue.cpp index 9146b85d11e879f7d1a4683ce69c204ea7bcb93c..5432b89552134b34fb58371bb1c24d3d6d109ffd 100644 --- a/catalogue/SqliteCatalogue.cpp +++ b/catalogue/SqliteCatalogue.cpp @@ -19,8 +19,6 @@ #include "catalogue/ArchiveFileRow.hpp" #include "catalogue/SqliteCatalogueSchema.hpp" #include "catalogue/SqliteCatalogue.hpp" -#include "common/exception/DatabaseConstraintError.hpp" -#include "common/exception/DatabasePrimaryKeyError.hpp" #include "common/exception/Exception.hpp" #include "common/exception/UserError.hpp" #include "common/make_unique.hpp" @@ -28,6 +26,8 @@ #include "common/Timer.hpp" #include "common/utils/utils.hpp" #include "rdbms/AutoRollback.hpp" +#include "rdbms/ConstraintError.hpp" +#include "rdbms/PrimaryKeyError.hpp" namespace cta { namespace catalogue { @@ -418,7 +418,7 @@ void SqliteCatalogue::fileWrittenToTape(rdbms::Conn &conn, const TapeFileWritten row.diskFileOwnerUid = event.diskFileOwnerUid; row.diskFileGid = event.diskFileGid; insertArchiveFile(conn, row); - } catch(exception::DatabasePrimaryKeyError &) { + } catch(rdbms::PrimaryKeyError &) { // Ignore this error } catch(...) { throw; diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 5296e06c6fd4709255e09ab4cd9e79ad78cf55bf..f1063e5b02b80f7e220f4c4fe766fd1de90c4ded 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -81,10 +81,6 @@ set (COMMON_LIB_SRC_FILES exception/Backtrace.cpp exception/BadAlloc.cpp exception/CommandLineNotParsed.cpp - exception/DatabaseCheckConstraintError.cpp - exception/DatabaseConstraintError.cpp - exception/DatabasePrimaryKeyError.cpp - exception/DatabaseUniqueError.cpp exception/DismountFailed.cpp exception/ForceDismountFailed.cpp exception/Errnum.cpp diff --git a/rdbms/CMakeLists.txt b/rdbms/CMakeLists.txt index a3fa9ad9df1423869bfd41044a83b795f10f201a..ff41876b4925ae35ca1090f8fe6ae245aca64900 100644 --- a/rdbms/CMakeLists.txt +++ b/rdbms/CMakeLists.txt @@ -21,15 +21,19 @@ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow") set (RDBMS_LIB_SRC_FILES AutoRollback.cpp + CheckConstraintError.cpp Conn.cpp ConnPool.cpp + ConstraintError.cpp Login.cpp LoginFactory.cpp NullDbValue.cpp + PrimaryKeyError.cpp rdbms.cpp Rset.cpp Stmt.cpp - StmtPool.cpp) + StmtPool.cpp + UniqueError.cpp) add_library (ctardbms SHARED ${RDBMS_LIB_SRC_FILES}) diff --git a/common/exception/DatabaseCheckConstraintError.cpp b/rdbms/CheckConstraintError.cpp similarity index 80% rename from common/exception/DatabaseCheckConstraintError.cpp rename to rdbms/CheckConstraintError.cpp index a80ed5daa675aa3536ac680943f8790963ffeddc..f1f9052d561c87368ef13ca13671596dd2bd955e 100644 --- a/common/exception/DatabaseCheckConstraintError.cpp +++ b/rdbms/CheckConstraintError.cpp @@ -16,25 +16,25 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "common/exception/DatabaseCheckConstraintError.hpp" +#include "rdbms/CheckConstraintError.hpp" namespace cta { -namespace exception { +namespace rdbms { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -DatabaseCheckConstraintError::DatabaseCheckConstraintError( +CheckConstraintError::CheckConstraintError( const std::string &context, const bool embedBacktrace): - DatabaseConstraintError(context, embedBacktrace) { + ConstraintError(context, embedBacktrace) { } //------------------------------------------------------------------------------ // destructor //------------------------------------------------------------------------------ -DatabaseCheckConstraintError::~DatabaseCheckConstraintError() noexcept { +CheckConstraintError::~CheckConstraintError() noexcept { } -} // namespace exception +} // namespace rdbms } // namespace cta diff --git a/common/exception/DatabaseCheckConstraintError.hpp b/rdbms/CheckConstraintError.hpp similarity index 76% rename from common/exception/DatabaseCheckConstraintError.hpp rename to rdbms/CheckConstraintError.hpp index 7a81d0503c26314a3913ee793b203820ae4a0bfd..b92f6a579c10187e8e37c3c59a518a9c67118efd 100644 --- a/common/exception/DatabaseCheckConstraintError.hpp +++ b/rdbms/CheckConstraintError.hpp @@ -18,18 +18,17 @@ #pragma once -#include "common/exception/DatabaseConstraintError.hpp" +#include "rdbms/ConstraintError.hpp" #include <string> - namespace cta { -namespace exception { +namespace rdbms { /** * A database constraint error. */ -class DatabaseCheckConstraintError : public DatabaseConstraintError { +class CheckConstraintError : public ConstraintError { public: /** @@ -40,15 +39,15 @@ public: * @param embedBacktrace whether to embed a backtrace of where the * exception was throw in the message */ - DatabaseCheckConstraintError(const std::string &context = "", const bool embedBacktrace = true); + CheckConstraintError(const std::string &context = "", const bool embedBacktrace = true); /** * Empty Destructor, explicitely non-throwing (needed for std::exception * inheritance) */ - ~DatabaseCheckConstraintError() noexcept override; + ~CheckConstraintError() noexcept override; -}; // class DatabaseCheckConstraintError +}; // class CheckConstraintError -} // namespace exception +} // namespace rdbms } // namespace cta diff --git a/common/exception/DatabaseConstraintError.cpp b/rdbms/ConstraintError.cpp similarity index 81% rename from common/exception/DatabaseConstraintError.cpp rename to rdbms/ConstraintError.cpp index d0b2f1e340bc7aefe2d9807b93cd98647a83ea49..cf39e97d6796c05d5e0474796f7e3617d1c85194 100644 --- a/common/exception/DatabaseConstraintError.cpp +++ b/rdbms/ConstraintError.cpp @@ -16,23 +16,23 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "common/exception/DatabaseConstraintError.hpp" +#include "rdbms/ConstraintError.hpp" namespace cta { -namespace exception { +namespace rdbms { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -DatabaseConstraintError::DatabaseConstraintError(const std::string &context, const bool embedBacktrace): +ConstraintError::ConstraintError(const std::string &context, const bool embedBacktrace): Exception(context, embedBacktrace) { } //------------------------------------------------------------------------------ // destructor //------------------------------------------------------------------------------ -DatabaseConstraintError::~DatabaseConstraintError() noexcept { +ConstraintError::~ConstraintError() noexcept { } -} // namespace exception +} // namespace rdbms } // namespace cta diff --git a/common/exception/DatabaseConstraintError.hpp b/rdbms/ConstraintError.hpp similarity index 79% rename from common/exception/DatabaseConstraintError.hpp rename to rdbms/ConstraintError.hpp index 60a92484972765e46c604a68db0b8414edac02e2..6c3557f6880b6b422c216c86ffc8a6543bb88a32 100644 --- a/common/exception/DatabaseConstraintError.hpp +++ b/rdbms/ConstraintError.hpp @@ -23,13 +23,13 @@ #include <string> -namespace cta { -namespace exception { +namespace cta { +namespace rdbms { /** * A database constraint error. */ -class DatabaseConstraintError : public cta::exception::Exception { +class ConstraintError : public cta::exception::Exception { public: /** @@ -40,15 +40,15 @@ public: * @param embedBacktrace whether to embed a backtrace of where the * exception was throw in the message */ - DatabaseConstraintError(const std::string &context = "", const bool embedBacktrace = true); + ConstraintError(const std::string &context = "", const bool embedBacktrace = true); /** * Empty Destructor, explicitely non-throwing (needed for std::exception * inheritance) */ - ~DatabaseConstraintError() noexcept override; + ~ConstraintError() noexcept override; -}; // class DatabaseConstraintError +}; // class ConstraintError -} // namespace exception +} // namespace rdbms } // namespace cta diff --git a/common/exception/DatabaseUniqueError.cpp b/rdbms/PrimaryKeyError.cpp similarity index 78% rename from common/exception/DatabaseUniqueError.cpp rename to rdbms/PrimaryKeyError.cpp index db0e01cbb6253212af780c4136dbe47ec2ad2f3e..1d69cedb7aee6878fb434e7388cf1c17c78b94ae 100644 --- a/common/exception/DatabaseUniqueError.cpp +++ b/rdbms/PrimaryKeyError.cpp @@ -16,23 +16,23 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "common/exception/DatabaseUniqueError.hpp" +#include "rdbms/PrimaryKeyError.hpp" namespace cta { -namespace exception { +namespace rdbms { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -DatabaseUniqueError::DatabaseUniqueError(const std::string &context, const bool embedBacktrace): - DatabaseConstraintError(context, embedBacktrace) { +PrimaryKeyError::PrimaryKeyError(const std::string &context, const bool embedBacktrace): + ConstraintError(context, embedBacktrace) { } //------------------------------------------------------------------------------ // destructor //------------------------------------------------------------------------------ -DatabaseUniqueError::~DatabaseUniqueError() noexcept { +PrimaryKeyError::~PrimaryKeyError() noexcept { } -} // namespace exception +} // namespace rdbms } // namespace cta diff --git a/common/exception/DatabaseUniqueError.hpp b/rdbms/PrimaryKeyError.hpp similarity index 77% rename from common/exception/DatabaseUniqueError.hpp rename to rdbms/PrimaryKeyError.hpp index caf511c7e964b01ec9c7047de3d11f2f2219d925..714c1558ceeecdd6d80b84ac915c78aa7511484b 100644 --- a/common/exception/DatabaseUniqueError.hpp +++ b/rdbms/PrimaryKeyError.hpp @@ -18,18 +18,18 @@ #pragma once -#include "common/exception/DatabaseConstraintError.hpp" +#include "rdbms/ConstraintError.hpp" #include <string> -namespace cta { -namespace exception { +namespace cta { +namespace rdbms { /** * A database constraint has been violated. */ -class DatabaseUniqueError : public DatabaseConstraintError { +class PrimaryKeyError : public ConstraintError { public: /** @@ -40,15 +40,15 @@ public: * @param embedBacktrace whether to embed a backtrace of where the * exception was throw in the message */ - DatabaseUniqueError(const std::string &context = "", const bool embedBacktrace = true); + PrimaryKeyError(const std::string &context = "", const bool embedBacktrace = true); /** * Empty Destructor, explicitely non-throwing (needed for std::exception * inheritance) */ - ~DatabaseUniqueError() noexcept override; + ~PrimaryKeyError() noexcept override; -}; // class DatabaseUniqueError +}; // class PrimaryKeyError -} // namespace exception +} // namespace rdbms } // namespace cta diff --git a/rdbms/StmtTest.cpp b/rdbms/StmtTest.cpp index a16c49311d67bf50fa0b053a293b6ba67a59e859..03ea228ec2450264e18928d38ef03dc7f91cec76 100644 --- a/rdbms/StmtTest.cpp +++ b/rdbms/StmtTest.cpp @@ -16,14 +16,14 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "common/exception/DatabaseCheckConstraintError.hpp" -#include "common/exception/DatabasePrimaryKeyError.hpp" -#include "common/exception/DatabaseUniqueError.hpp" #include "common/exception/Exception.hpp" #include "common/make_unique.hpp" #include "common/utils/utils.hpp" +#include "rdbms/CheckConstraintError.hpp" #include "rdbms/ConnPool.hpp" +#include "rdbms/PrimaryKeyError.hpp" #include "rdbms/StmtTest.hpp" +#include "rdbms/UniqueError.hpp" #include <gtest/gtest.h> @@ -420,7 +420,7 @@ TEST_P(cta_rdbms_StmtTest, insert_with_bindString_invalid_bool_value) { auto stmt = m_conn.createStmt(sql); stmt.bindString(":BOOL_COL", insertValue); - ASSERT_THROW(stmt.executeNonQuery(), cta::exception::DatabaseCheckConstraintError); + ASSERT_THROW(stmt.executeNonQuery(), CheckConstraintError); } } @@ -474,10 +474,10 @@ TEST_P(cta_rdbms_StmtTest, insert_same_primary_twice) { case Login::DBTYPE_IN_MEMORY: case Login::DBTYPE_ORACLE: case Login::DBTYPE_POSTGRESQL: - ASSERT_THROW(stmt.executeNonQuery(), cta::exception::DatabaseUniqueError); + ASSERT_THROW(stmt.executeNonQuery(), UniqueError); break; default: - ASSERT_THROW(stmt.executeNonQuery(), cta::exception::DatabasePrimaryKeyError); + ASSERT_THROW(stmt.executeNonQuery(), PrimaryKeyError); } } } diff --git a/common/exception/DatabasePrimaryKeyError.cpp b/rdbms/UniqueError.cpp similarity index 77% rename from common/exception/DatabasePrimaryKeyError.cpp rename to rdbms/UniqueError.cpp index 9e5cea183dfcb6b2c8df0d2ea8b15bd82755625d..5ed7377aaabb484e2b7de79c890bb772baab665d 100644 --- a/common/exception/DatabasePrimaryKeyError.cpp +++ b/rdbms/UniqueError.cpp @@ -16,23 +16,23 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "common/exception/DatabasePrimaryKeyError.hpp" +#include "rdbms/UniqueError.hpp" namespace cta { -namespace exception { +namespace rdbms { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -DatabasePrimaryKeyError::DatabasePrimaryKeyError(const std::string &context, const bool embedBacktrace): - DatabaseConstraintError(context, embedBacktrace) { +UniqueError::UniqueError(const std::string &context, const bool embedBacktrace): + ConstraintError(context, embedBacktrace) { } //------------------------------------------------------------------------------ // destructor //------------------------------------------------------------------------------ -DatabasePrimaryKeyError::~DatabasePrimaryKeyError() noexcept { +UniqueError::~UniqueError() noexcept { } -} // namespace exception +} // namespace rdbms } // namespace cta diff --git a/common/exception/DatabasePrimaryKeyError.hpp b/rdbms/UniqueError.hpp similarity index 76% rename from common/exception/DatabasePrimaryKeyError.hpp rename to rdbms/UniqueError.hpp index 84b756b88bbd79bb9de08abc90a0018440d52002..a67aa922308b22bb8a738e6b75ad7e9460eab895 100644 --- a/common/exception/DatabasePrimaryKeyError.hpp +++ b/rdbms/UniqueError.hpp @@ -18,18 +18,18 @@ #pragma once -#include "common/exception/DatabaseConstraintError.hpp" +#include "rdbms/ConstraintError.hpp" #include <string> -namespace cta { -namespace exception { +namespace cta { +namespace rdbms { /** * A database constraint has been violated. */ -class DatabasePrimaryKeyError : public DatabaseConstraintError { +class UniqueError : public ConstraintError { public: /** @@ -40,15 +40,15 @@ public: * @param embedBacktrace whether to embed a backtrace of where the * exception was throw in the message */ - DatabasePrimaryKeyError(const std::string &context = "", const bool embedBacktrace = true); + UniqueError(const std::string &context = "", const bool embedBacktrace = true); /** * Empty Destructor, explicitely non-throwing (needed for std::exception * inheritance) */ - ~DatabasePrimaryKeyError() noexcept override; + ~UniqueError() noexcept override; -}; // class DatabasePrimaryKeyError +}; // class UniqueError -} // namespace exception +} // namespace rdbms } // namespace cta diff --git a/rdbms/wrapper/MysqlRset.cpp b/rdbms/wrapper/MysqlRset.cpp index ee45544fba3c269359e8da4a089b412232dff518..d25c8c79f3cd722b086c6f654f2a18d2e8100069 100644 --- a/rdbms/wrapper/MysqlRset.cpp +++ b/rdbms/wrapper/MysqlRset.cpp @@ -16,11 +16,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "common/exception/DatabaseConstraintError.hpp" -#include "common/exception/DatabasePrimaryKeyError.hpp" #include "common/exception/Exception.hpp" #include "common/exception/Errnum.hpp" +#include "rdbms/ConstraintError.hpp" #include "rdbms/NullDbValue.hpp" +#include "rdbms/PrimaryKeyError.hpp" #include "rdbms/wrapper/Mysql.hpp" #include "rdbms/wrapper/MysqlRset.hpp" #include "rdbms/wrapper/MysqlStmt.hpp" diff --git a/rdbms/wrapper/MysqlStmt.cpp b/rdbms/wrapper/MysqlStmt.cpp index fd3cc16f84611c47cae93449cac3a790fe82b47c..7d9d48eb5154197b719e62d8c0214f1fead7ea10 100644 --- a/rdbms/wrapper/MysqlStmt.cpp +++ b/rdbms/wrapper/MysqlStmt.cpp @@ -16,12 +16,12 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "common/exception/DatabaseCheckConstraintError.hpp" -#include "common/exception/DatabasePrimaryKeyError.hpp" #include "common/exception/Exception.hpp" #include "common/make_unique.hpp" #include "common/threading/MutexLocker.hpp" +#include "rdbms/CheckConstraintError.hpp" +#include "rdbms/PrimaryKeyError.hpp" #include "rdbms/wrapper/MysqlConn.hpp" #include "rdbms/wrapper/MysqlRset.hpp" #include "rdbms/wrapper/MysqlStmt.hpp" @@ -380,10 +380,10 @@ void MysqlStmt::executeNonQuery() { switch(rc) { case ER_DUP_ENTRY: - throw exception::DatabasePrimaryKeyError(std::string(__FUNCTION__) + " " + msg); + throw PrimaryKeyError(std::string(__FUNCTION__) + " " + msg); break; case 4025: // Newer MariaDB versions have ER_CONSTRAINT_FAILED = 4025 - throw exception::DatabaseCheckConstraintError(std::string(__FUNCTION__) + " " + msg); + throw CheckConstraintError(std::string(__FUNCTION__) + " " + msg); break; } diff --git a/rdbms/wrapper/OcciStmt.cpp b/rdbms/wrapper/OcciStmt.cpp index 560862d145664ec824c5de2de5cab50b0e8dd5e6..a7f65171a4f11ab5d3daafa94adfcb3550c138c1 100644 --- a/rdbms/wrapper/OcciStmt.cpp +++ b/rdbms/wrapper/OcciStmt.cpp @@ -16,13 +16,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "common/exception/DatabaseCheckConstraintError.hpp" -#include "common/exception/DatabasePrimaryKeyError.hpp" -#include "common/exception/DatabaseUniqueError.hpp" #include "common/exception/Exception.hpp" #include "common/exception/LostDatabaseConnection.hpp" #include "common/make_unique.hpp" #include "common/threading/MutexLocker.hpp" +#include "rdbms/CheckConstraintError.hpp" +#include "rdbms/PrimaryKeyError.hpp" +#include "rdbms/UniqueError.hpp" #include "rdbms/wrapper/OcciColumn.hpp" #include "rdbms/wrapper/OcciConn.hpp" #include "rdbms/wrapper/OcciRset.hpp" @@ -274,9 +274,9 @@ void OcciStmt::executeNonQuery() { switch(ex.getErrorCode()) { case 1: - throw exception::DatabaseUniqueError(msg.str()); + throw UniqueError(msg.str()); case 2290: - throw exception::DatabaseCheckConstraintError(msg.str()); + throw CheckConstraintError(msg.str()); default: throw exception::Exception(msg.str()); } diff --git a/rdbms/wrapper/Postgres.hpp b/rdbms/wrapper/Postgres.hpp index f7e3ee223f81bfcd0d2badc23d11e2793f7ecb2e..5c3c9029335f8fb67f92fa4a43116e7163a26af0 100644 --- a/rdbms/wrapper/Postgres.hpp +++ b/rdbms/wrapper/Postgres.hpp @@ -18,10 +18,10 @@ #pragma once -#include "common/exception/DatabaseCheckConstraintError.hpp" -#include "common/exception/DatabaseUniqueError.hpp" #include "common/exception/Exception.hpp" #include "common/exception/LostDatabaseConnection.hpp" +#include "rdbms/CheckConstraintError.hpp" +#include "rdbms/UniqueError.hpp" #include <algorithm> #include <cstring> @@ -95,10 +95,10 @@ public: throw exception::LostDatabaseConnection(dbmsg); } if (uniqueViolation) { - throw exception::DatabaseUniqueError(dbmsg); + throw UniqueError(dbmsg); } if (checkViolation) { - throw exception::DatabaseCheckConstraintError(dbmsg); + throw CheckConstraintError(dbmsg); } throw exception::Exception(dbmsg); } diff --git a/rdbms/wrapper/PostgresStmtTest.cpp b/rdbms/wrapper/PostgresStmtTest.cpp index 8d27cd91fadf925acc0350ba677c92048f376d6b..812a70201e44edcc34a976d4a84ab7248db9b859 100644 --- a/rdbms/wrapper/PostgresStmtTest.cpp +++ b/rdbms/wrapper/PostgresStmtTest.cpp @@ -16,8 +16,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "common/exception/DatabaseConstraintError.hpp" #include "common/make_unique.hpp" +#include "rdbms/ConstraintError.hpp" #include "rdbms/wrapper/PostgresConn.hpp" #include "rdbms/wrapper/PostgresRset.hpp" #include "rdbms/wrapper/PostgresStmt.hpp" diff --git a/rdbms/wrapper/SqliteRset.cpp b/rdbms/wrapper/SqliteRset.cpp index e332320f23a93855c1597eda39986c3dfe00bfc2..d01cf7d3fecc4c6ccb4097e7ca2e3f056ce017da 100644 --- a/rdbms/wrapper/SqliteRset.cpp +++ b/rdbms/wrapper/SqliteRset.cpp @@ -16,11 +16,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "common/exception/DatabaseConstraintError.hpp" -#include "common/exception/DatabasePrimaryKeyError.hpp" #include "common/exception/Exception.hpp" #include "common/exception/Errnum.hpp" +#include "rdbms/ConstraintError.hpp" #include "rdbms/NullDbValue.hpp" +#include "rdbms/PrimaryKeyError.hpp" #include "rdbms/wrapper/Sqlite.hpp" #include "rdbms/wrapper/SqliteRset.hpp" #include "rdbms/wrapper/SqliteStmt.hpp" @@ -158,9 +158,9 @@ bool SqliteRset::next() { switch(stepRc) { case SQLITE_CONSTRAINT_PRIMARYKEY: - throw exception::DatabasePrimaryKeyError(msg.str()); + throw PrimaryKeyError(msg.str()); case SQLITE_CONSTRAINT: - throw exception::DatabaseConstraintError(msg.str()); + throw ConstraintError(msg.str()); default: throw exception::Exception(msg.str()); } diff --git a/rdbms/wrapper/SqliteStmt.cpp b/rdbms/wrapper/SqliteStmt.cpp index 0b2c228faf3b6b9cdddcb653523033b08037cd9c..d063aaf2ba5582b0e46755e7d290f1fd9e918079 100644 --- a/rdbms/wrapper/SqliteStmt.cpp +++ b/rdbms/wrapper/SqliteStmt.cpp @@ -16,13 +16,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "common/exception/DatabaseCheckConstraintError.hpp" -#include "common/exception/DatabaseConstraintError.hpp" -#include "common/exception/DatabasePrimaryKeyError.hpp" -#include "common/exception/DatabaseUniqueError.hpp" #include "common/exception/Exception.hpp" #include "common/make_unique.hpp" #include "common/threading/MutexLocker.hpp" +#include "rdbms/CheckConstraintError.hpp" +#include "rdbms/ConstraintError.hpp" +#include "rdbms/PrimaryKeyError.hpp" +#include "rdbms/UniqueError.hpp" #include "rdbms/wrapper/Sqlite.hpp" #include "rdbms/wrapper/SqliteConn.hpp" #include "rdbms/wrapper/SqliteRset.hpp" @@ -288,16 +288,16 @@ void SqliteStmt::executeNonQuery() { switch(stepRc) { case SQLITE_CONSTRAINT: - throw exception::DatabaseConstraintError(msg.str()); + throw ConstraintError(msg.str()); case SQLITE_CONSTRAINT_CHECK: - throw exception::DatabaseCheckConstraintError(msg.str()); + throw CheckConstraintError(msg.str()); case SQLITE_CONSTRAINT_PRIMARYKEY: - throw exception::DatabasePrimaryKeyError(msg.str()); + throw PrimaryKeyError(msg.str()); case SQLITE_CONSTRAINT_UNIQUE: - throw exception::DatabaseUniqueError(msg.str()); + throw UniqueError(msg.str()); default: if ((stepRc & 0xFF) == SQLITE_CONSTRAINT) - throw exception::DatabaseConstraintError(msg.str()); + throw ConstraintError(msg.str()); else throw exception::Exception(msg.str()); } diff --git a/rdbms/wrapper/SqliteStmtTest.cpp b/rdbms/wrapper/SqliteStmtTest.cpp index 1ec7e9a2e65fdac61a03b6fe7d271af8afc3dc0e..6f286f530286dd14062bdce40a8d25853cc1c79f 100644 --- a/rdbms/wrapper/SqliteStmtTest.cpp +++ b/rdbms/wrapper/SqliteStmtTest.cpp @@ -16,8 +16,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "common/exception/DatabaseConstraintError.hpp" -#include "common/exception/DatabasePrimaryKeyError.hpp" +#include "rdbms/ConstraintError.hpp" +#include "rdbms/PrimaryKeyError.hpp" #include "rdbms/wrapper/SqliteConn.hpp" #include "rdbms/wrapper/SqliteRset.hpp" #include "rdbms/wrapper/SqliteStmt.hpp" @@ -362,6 +362,7 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, isolated_transaction) { TEST_F(cta_rdbms_wrapper_SqliteStmtTest, executeNonQuery_insert_violating_primary_key) { using namespace cta; + using namespace cta::rdbms; using namespace cta::rdbms::wrapper; // Create a connection a memory resident database @@ -402,12 +403,13 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, executeNonQuery_insert_violating_primar ":COL1);"; auto stmt = conn.createStmt(sql); stmt->bindUint64(":COL1", 1); - ASSERT_THROW(stmt->executeNonQuery(), exception::DatabasePrimaryKeyError); + ASSERT_THROW(stmt->executeNonQuery(), PrimaryKeyError); } } TEST_F(cta_rdbms_wrapper_SqliteStmtTest, executeQuery_insert_violating_primary_key) { using namespace cta; + using namespace cta::rdbms; using namespace cta::rdbms::wrapper; // Create a connection a memory resident database @@ -449,7 +451,7 @@ TEST_F(cta_rdbms_wrapper_SqliteStmtTest, executeQuery_insert_violating_primary_k auto stmt = conn.createStmt(sql); stmt->bindUint64(":COL1", 1); auto rset = stmt->executeQuery(); - ASSERT_THROW(rset->next(), exception::DatabasePrimaryKeyError); + ASSERT_THROW(rset->next(), PrimaryKeyError); } }