From 05f96bc67e0acb7a6563c52de61349c94c56478c Mon Sep 17 00:00:00 2001 From: acezen Date: Tue, 15 Aug 2023 06:55:09 +0000 Subject: [PATCH] [Feat][C++] Output the error message when access value in Result fail --- cpp/include/gar/external/result.hpp | 1 + cpp/include/gar/graph_info.h | 4 ++-- cpp/test/test_builder.cc | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cpp/include/gar/external/result.hpp b/cpp/include/gar/external/result.hpp index a82a1daea..e2003d0fc 100644 --- a/cpp/include/gar/external/result.hpp +++ b/cpp/include/gar/external/result.hpp @@ -4285,6 +4285,7 @@ auto RESULT_NS_IMPL::detail::throw_bad_result_access(E&& error) -> void >; throw exception_type{ + error.message(), detail::forward(error) }; #endif diff --git a/cpp/include/gar/graph_info.h b/cpp/include/gar/graph_info.h index df6d34ce4..370a1138f 100644 --- a/cpp/include/gar/graph_info.h +++ b/cpp/include/gar/graph_info.h @@ -1182,7 +1182,7 @@ class GraphInfo { noexcept { if (vertex2info_.find(label) == vertex2info_.end()) { return Status::KeyError("The vertex info of ", label, - "is not found in graph info."); + " is not found in graph info."); } return vertex2info_.at(label); } @@ -1219,7 +1219,7 @@ class GraphInfo { const std::string& label, const std::string& property) const noexcept { if (vertex2info_.find(label) == vertex2info_.end()) { return Status::KeyError("The vertex info of ", label, - "is not found in graph info."); + " is not found in graph info."); } return vertex2info_.at(label).GetPropertyGroup(property); } diff --git a/cpp/test/test_builder.cc b/cpp/test/test_builder.cc index 8c8291413..a3759fb51 100644 --- a/cpp/test/test_builder.cc +++ b/cpp/test/test_builder.cc @@ -178,7 +178,7 @@ TEST_CASE("test_edges_builder") { lines++; std::string val; std::istringstream readstr(line); - int64_t s, d; + int64_t s = 0, d = 0; for (int i = 0; i < 3; i++) { getline(readstr, val, '|'); if (i == 0) {