Skip to content
Snippets Groups Projects
Commit 84773e02 authored by florian's avatar florian
Browse files

API: Rename UnkownConnectionError to ConnectionConfigurationError

parent 816c6eec
Branches
Tags
1 merge request!17F file read error
Pipeline #14578 passed
Pipeline: caosdb-cppinttest

#14579

    This commit is part of merge request !17. Comments created here will be created in the context of that merge request.
    ...@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
    ### Changed ### Changed
    * Integer values are 32 bit now. * Integer values are 32 bit now.
    * Rename UnkownConnectionError to ConnectionConfigurationError
    ### Deprecated ### Deprecated
    ......
    ...@@ -103,10 +103,10 @@ public: ...@@ -103,10 +103,10 @@ public:
    /** /**
    * @brief The connection isn't known to the ConnectionManager under this name. * @brief The connection isn't known to the ConnectionManager under this name.
    */ */
    class UnknownConnectionError : public Exception { class ConnectionConfigurationError : public Exception {
    public: public:
    explicit UnknownConnectionError(const std::string &what_arg) explicit ConnectionConfigurationError(const std::string &what_arg)
    : Exception(StatusCode::UNKNOWN_CONNECTION_ERROR, what_arg) {} : Exception(StatusCode::CONNECTION_CONFIGURATION_ERROR, what_arg) {}
    }; };
    } // namespace caosdb::exceptions } // namespace caosdb::exceptions
    ......
    ...@@ -62,7 +62,7 @@ enum StatusCode { ...@@ -62,7 +62,7 @@ enum StatusCode {
    GENERIC_ERROR = 21, GENERIC_ERROR = 21,
    GENERIC_TRANSACTION_ERROR = 22, GENERIC_TRANSACTION_ERROR = 22,
    CONFIGURATION_ERROR = 23, CONFIGURATION_ERROR = 23,
    UNKNOWN_CONNECTION_ERROR = 24, CONNECTION_CONFIGURATION_ERROR = 24,
    TRANSACTION_STATUS_ERROR = 25, TRANSACTION_STATUS_ERROR = 25,
    TRANSACTION_TYPE_ERROR = 26, TRANSACTION_TYPE_ERROR = 26,
    UNSUPPORTED_FEATURE = 27, UNSUPPORTED_FEATURE = 27,
    ...@@ -77,7 +77,6 @@ enum StatusCode { ...@@ -77,7 +77,6 @@ enum StatusCode {
    FILE_DOWNLOAD_ERROR = 36, FILE_DOWNLOAD_ERROR = 36,
    ENUM_MAPPING_ERROR = 37, ENUM_MAPPING_ERROR = 37,
    SPOILED = 38, SPOILED = 38,
    FILE_CANNOT_BE_READ = 39,
    OTHER_CLIENT_ERROR = 9999, OTHER_CLIENT_ERROR = 9999,
    }; };
    ......
    ...@@ -88,13 +88,7 @@ auto getEnumValueFromName<caosdb::entity::Role>(const std::string &name) -> caos ...@@ -88,13 +88,7 @@ auto getEnumValueFromName<caosdb::entity::Role>(const std::string &name) -> caos
    */ */
    inline auto load_string_file(const path &path) -> std::string { inline auto load_string_file(const path &path) -> std::string {
    std::string result; std::string result;
    // TODO(htw)
    // try {
    boost::filesystem::load_string_file(path, result); boost::filesystem::load_string_file(path, result);
    // } catch (const std::exception &exc) {
    // throw caosdb::exceptions::Exception(StatusCode::FILE_CANNOT_BE_READ ,
    // "Cannot read the following file: "+ path.string());
    // }
    return result; return result;
    } }
    ......
    ...@@ -109,8 +109,8 @@ auto ConnectionManager::mGetConnection(const std::string &name) const ...@@ -109,8 +109,8 @@ auto ConnectionManager::mGetConnection(const std::string &name) const
    auto connection = ConfigurationManager::GetConnectionConfiguration(name); auto connection = ConfigurationManager::GetConnectionConfiguration(name);
    connections[name] = std::make_shared<Connection>(*connection.release()); connections[name] = std::make_shared<Connection>(*connection.release());
    } catch (const caosdb::exceptions::ConfigurationError &exc) { } catch (const caosdb::exceptions::ConfigurationError &exc) {
    throw caosdb::exceptions::UnknownConnectionError("Error with the connection named '" + name + throw caosdb::exceptions::ConnectionConfigurationError("Error with the connection named '" +
    "': " + exc.what()); name + "': " + exc.what());
    } }
    } }
    return this->connections.at(name); return this->connections.at(name);
    ......
    ...@@ -131,8 +131,9 @@ auto get_status_description(int code) -> const std::string & { ...@@ -131,8 +131,9 @@ auto get_status_description(int code) -> const std::string & {
    "The transaction terminated unsuccessfully with transaction errors."}, "The transaction terminated unsuccessfully with transaction errors."},
    {StatusCode::CONFIGURATION_ERROR, {StatusCode::CONFIGURATION_ERROR,
    "An error occurred during the configuration of the ConfigurationManager."}, "An error occurred during the configuration of the ConfigurationManager."},
    {StatusCode::UNKNOWN_CONNECTION_ERROR, {StatusCode::CONNECTION_CONFIGURATION_ERROR,
    "The ConnectionManager does not know any connection of this name."}, "Wither there is no connection of the given name or the given connection has a faulty "
    "configuration"},
    {StatusCode::TRANSACTION_STATUS_ERROR, {StatusCode::TRANSACTION_STATUS_ERROR,
    "The Transaction is in a wrong state for the attempted action."}, "The Transaction is in a wrong state for the attempted action."},
    {StatusCode::TRANSACTION_TYPE_ERROR, {StatusCode::TRANSACTION_TYPE_ERROR,
    ......
    ...@@ -248,7 +248,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, ...@@ -248,7 +248,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
    if (out->_deletable) { if (out->_deletable) {
    return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
    } }
    // TODO(htw) eitehr check for file existence or call CreateCertificateProvider?
    out->wrapped_certificate_provider = out->wrapped_certificate_provider =
    new caosdb::configuration::PemFileCertificateProvider(std::string(path)); new caosdb::configuration::PemFileCertificateProvider(std::string(path));
    out->_deletable = true; out->_deletable = true;
    ......
    ...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
    #include "caosdb/certificate_provider.h" // for PemCertificateProvider #include "caosdb/certificate_provider.h" // for PemCertificateProvider
    #include "caosdb/configuration.h" // for InsecureConnectionConfigura... #include "caosdb/configuration.h" // for InsecureConnectionConfigura...
    #include "caosdb/connection.h" // for ConnectionManager #include "caosdb/connection.h" // for ConnectionManager
    #include "caosdb/exceptions.h" // for UnknownConnectionError #include "caosdb/exceptions.h" // for ConnectionConfigurationError
    #include "caosdb_test_utility.h" // for EXPECT_THROW_MESSAGE, TEST_... #include "caosdb_test_utility.h" // for EXPECT_THROW_MESSAGE, TEST_...
    #include <gtest/gtest-message.h> // for Message #include <gtest/gtest-message.h> // for Message
    #include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestPartR... #include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestPartR...
    ...@@ -66,13 +66,13 @@ TEST_F(test_connection, configure_ssl_localhost_8080) { ...@@ -66,13 +66,13 @@ TEST_F(test_connection, configure_ssl_localhost_8080) {
    TEST_F(test_connection, connection_manager_unknown_connection) { TEST_F(test_connection, connection_manager_unknown_connection) {
    EXPECT_THROW_MESSAGE( EXPECT_THROW_MESSAGE(
    ConnectionManager::GetConnection("test"), caosdb::exceptions::UnknownConnectionError, ConnectionManager::GetConnection("test"), caosdb::exceptions::ConnectionConfigurationError,
    "Error with the connection named 'test': The connection 'test' has not been defined."); "Error with the connection named 'test': The connection 'test' has not been defined.");
    } }
    TEST_F(test_connection, connection_missing_certificate) { TEST_F(test_connection, connection_missing_certificate) {
    EXPECT_THROW_MESSAGE(ConnectionManager::GetConnection("missing"), EXPECT_THROW_MESSAGE(ConnectionManager::GetConnection("missing"),
    caosdb::exceptions::UnknownConnectionError, caosdb::exceptions::ConnectionConfigurationError,
    std::string("Error with the connection named 'missing': ") + std::string("Error with the connection named 'missing': ") +
    "File does not exist (server_certificate_path): /missing"); "File does not exist (server_certificate_path): /missing");
    } }
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment