diff --git a/src/orm/connectors/connectionfactory.cpp b/src/orm/connectors/connectionfactory.cpp index 78d53a46f..e3c0090bc 100644 --- a/src/orm/connectors/connectionfactory.cpp +++ b/src/orm/connectors/connectionfactory.cpp @@ -25,7 +25,8 @@ ConnectionFactory::createConnector(const QVariantHash &config) const { // This method is public, so I left this check here if (!config.contains(driver_)) - throw std::domain_error("A 'driver' configuration parameter must be specified."); + throw Exceptions::RuntimeError( + "A 'driver' configuration parameter must be specified."); const auto driver = config[driver_].value(); @@ -41,8 +42,8 @@ ConnectionFactory::createConnector(const QVariantHash &config) const // if (driver == "SQLSRV") // return std::make_unique(); - throw std::domain_error( - "Unsupported driver '" + driver.toStdString() + "'."); + throw Exceptions::RuntimeError(QStringLiteral("Unsupported driver '%1'.") + .arg(driver)); } QVariantHash & @@ -155,15 +156,15 @@ ConnectionFactory::createConnection( // return std::make_unique(std::move(connection), database, // prefix, config); - throw std::domain_error( - "Unsupported driver '" + driver.toStdString() + "'."); + throw Exceptions::RuntimeError(QStringLiteral("Unsupported driver '%1'.") + .arg(driver)); } QStringList ConnectionFactory::parseHosts(const QVariantHash &config) const { if (!config.contains(host_)) - // TODO now unify exception, std::domain_error is for user code, create own exceptions and use InvalidArgumentError, or runtime/logic error silverqx - throw std::domain_error("Database 'host' configuration parameter is required."); + throw Exceptions::RuntimeError( + "Database 'host' configuration parameter is required."); auto hosts = config[host_].value(); @@ -176,8 +177,9 @@ void ConnectionFactory::validateHosts(const QStringList &hosts) const { for (const auto &host : hosts) if (host.isEmpty()) - throw std::domain_error("Database 'host' configuration parameter " - "can not contain empty value."); + throw Exceptions::RuntimeError( + "Database 'host' configuration parameter can not contain empty " + "value."); } } // namespace Orm::Connectors diff --git a/src/orm/connectors/sqliteconnector.cpp b/src/orm/connectors/sqliteconnector.cpp index 72e468536..5b743d779 100644 --- a/src/orm/connectors/sqliteconnector.cpp +++ b/src/orm/connectors/sqliteconnector.cpp @@ -4,7 +4,6 @@ #include #include "orm/constants.hpp" -#include "orm/exceptions/invalidargumenterror.hpp" #include "orm/exceptions/queryerror.hpp" #include "orm/utils/type.hpp" @@ -93,7 +92,7 @@ void SQLiteConnector::checkDatabaseExists(const QVariantHash &config) const checkDatabaseExists = config[check_database_exists].value(); if (checkDatabaseExists && !QFile::exists(path)) - throw Exceptions::InvalidArgumentError( + throw Exceptions::RuntimeError( QStringLiteral("SQLite Database file '%1' does not exist.").arg(path)); } diff --git a/src/orm/databaseconnection.cpp b/src/orm/databaseconnection.cpp index 251cfdf80..9b9dd3b01 100644 --- a/src/orm/databaseconnection.cpp +++ b/src/orm/databaseconnection.cpp @@ -162,7 +162,6 @@ QSqlQuery DatabaseConnection::statement(const QString &queryString, include the bindings with SQL, which will make this exception a lot more helpful to the developer instead of just the database's errors. */ throw Exceptions::QueryError( - // TODO next use __tiny_func__ in similar statements/exceptions silverqx QStringLiteral("Statement in %1() failed.").arg(functionName), query, bindings_); });