Skip to content
Snippets Groups Projects
Commit 07b15011 authored by Joscha Schmiedt's avatar Joscha Schmiedt
Browse files

Merge branch 'f-better-errors' into 'dev'

F better errors

See merge request !59
parents a2691ff3 92169ec2
No related branches found
No related tags found
2 merge requests!61Release 0.3.0,!59F better errors
Pipeline #57536 passed with warnings
Pipeline: caosdb-cppinttest

#57545

    ......@@ -37,9 +37,14 @@ class LinkAheadConan(ConanFile):
    self.tool_requires("cmake/[>=3.13]")
    self.tool_requires("boost/1.80.0")
    self.test_requires("gtest/1.11.0")
    self.requires("grpc/1.48.4")
    self.requires("protobuf/3.21.12")
    self.requires("boost/1.80.0")
    def requirements(self):
    self.requires("grpc/1.48.4", transitive_headers=True, transitive_libs=True)
    self.requires("protobuf/3.21.12", transitive_headers=True, transitive_libs=True)
    self.requires("boost/1.80.0", transitive_headers=True, transitive_libs=True)
    def test_requirements(self):
    self.test_requires("gtest/1.11.0")
    def config_options(self):
    if self.settings.os == "Windows":
    ......
    ......@@ -43,20 +43,27 @@ const auto logger_name = "liblinkahead";
    auto main() -> int {
    std::cout << "LinkAhead C++ client (liblinkahead " << linkahead::LIBLINKAHEAD_VERSION_MINOR << "."
    std::cout << "LinkAhead C++ client (liblinkahead " << linkahead::LIBLINKAHEAD_VERSION_MAJOR << "."
    << linkahead::LIBLINKAHEAD_VERSION_MINOR << "." << linkahead::LIBLINKAHEAD_VERSION_PATCH
    << ")\n"
    << std::endl;
    << ")\n";
    try {
    const auto &connection = linkahead::connection::ConnectionManager::GetDefaultConnection();
    connection->RetrieveVersionInfoNoExceptions();
    auto status = connection->RetrieveVersionInfoNoExceptions();
    if (status.GetCode() == linkahead::CONNECTION_ERROR) {
    const auto connection_config =
    linkahead::configuration::ConfigurationManager::GetDefaultConnectionConfiguration();
    std::cout << "ConnectionError: Cannot connect to " << connection_config->GetHost() << ":"
    << connection_config->GetPort() << '\n';
    return 1;
    }
    // get version info of the server
    const auto &v_info = connection->GetVersionInfo();
    std::cout << "Server Version: " << v_info->GetMajor() << "." << v_info->GetMinor() << "."
    << v_info->GetPatch() << "-" << v_info->GetPreRelease() << "-" << v_info->GetBuild()
    << std::endl;
    << '\n';
    // retrieve an entity
    auto transaction(connection->CreateTransaction());
    ......@@ -67,12 +74,12 @@ auto main() -> int {
    << "status: " << t_stat.GetCode() << " // " << t_stat.GetDescription();
    const auto &result_set = transaction->GetResultSet();
    for (const auto &entity : result_set) {
    std::cout << entity.ToString() << std::endl;
    std::cout << entity.ToString() << '\n';
    }
    // execute a query
    std::string query("FIND Property \"Prop *\"");
    std::cout << "Trying to execute a query:\n" << query << std::endl;
    std::cout << "Trying to execute a query:\n" << query << '\n';
    auto q_transaction(connection->CreateTransaction());
    q_transaction->Query(query);
    q_transaction->ExecuteAsynchronously();
    ......@@ -81,18 +88,18 @@ auto main() -> int {
    << "status: " << t_stat.GetCode() << " // " << t_stat.GetDescription();
    const auto &result_set_2 = q_transaction->GetResultSet();
    for (const auto &entity : result_set_2) {
    std::cout << entity.ToString() << std::endl;
    std::cout << entity.ToString() << '\n';
    }
    return 0;
    } catch (const linkahead::exceptions::ConfigurationError &exc) {
    std::cout << "ConfigurationError: " << exc.what() << std::endl;
    std::cout << "ConfigurationError: " << exc.what() << '\n';
    return exc.GetCode();
    } catch (const std::exception &exc) {
    std::cout << "Exception: " << exc.what() << std::endl;
    std::cout << "Exception: " << exc.what() << '\n';
    return 1;
    } catch (...) {
    std::cout << "Some other exception." << std::endl;
    std::cout << "Some other exception." << '\n';
    return 2;
    }
    }
    ......@@ -108,6 +108,10 @@ template <> auto getEnumValueFromName<Role>(const std::string &name) -> Role {
    auto load_string_file(const path &file_path) -> std::string {
    std::string result;
    if (!exists(file_path)) {
    throw std::runtime_error("File not found: " + file_path.string());
    }
    // adapted from boost::filesystem::load_string_file, which was removed in 1.84
    std::ifstream file;
    file.exceptions(std::ios_base::failbit | std::ios_base::badbit);
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment