From bffef1a653cd59e69b94c0a0d9a6c7079edec3d6 Mon Sep 17 00:00:00 2001 From: jbajic Date: Tue, 22 Nov 2022 11:13:23 +0100 Subject: [PATCH] Use experimental source location --- src/expr/interpret/eval.hpp | 8 ++++---- src/storage/v3/result.hpp | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/expr/interpret/eval.hpp b/src/expr/interpret/eval.hpp index 85911678d..758ea3797 100644 --- a/src/expr/interpret/eval.hpp +++ b/src/expr/interpret/eval.hpp @@ -100,7 +100,7 @@ class ExpressionEvaluator : public ExpressionVisitor { #undef BINARY_OPERATOR_VISITOR #undef UNARY_OPERATOR_VISITOR - void HandleShardError(Error &shard_error, const std::string_view accessed_object) { + void HandleObjectAccessError(Error &shard_error, const std::string_view accessed_object) { switch (shard_error) { case Error::DELETED_OBJECT: throw ExpressionRuntimeException("Trying to access {} on a deleted object.", accessed_object); @@ -418,7 +418,7 @@ class ExpressionEvaluator : public ExpressionVisitor { has_label = vertex.HasLabel(StorageView::NEW, GetLabel(label)); } if (has_label.HasError()) { - HandleShardError(has_label.GetError().code, "labels"); + HandleObjectAccessError(has_label.GetError().code, "labels"); } return *has_label; } @@ -756,7 +756,7 @@ class ExpressionEvaluator : public ExpressionVisitor { maybe_prop = record_accessor.GetProperty(StorageView::NEW, ctx_->properties[prop.ix]); } if (maybe_prop.HasError()) { - HandleShardError(maybe_prop.GetError().code, "property"); + HandleObjectAccessError(maybe_prop.GetError().code, "property"); } return conv_(*maybe_prop, ctx_->memory); } @@ -775,7 +775,7 @@ class ExpressionEvaluator : public ExpressionVisitor { maybe_prop = record_accessor.GetProperty(view_, dba_->NameToProperty(name)); } if (maybe_prop.HasError()) { - HandleShardError(maybe_prop.GetError().code, "property"); + HandleObjectAccessError(maybe_prop.GetError().code, "property"); } return conv_(*maybe_prop, ctx_->memory); } diff --git a/src/storage/v3/result.hpp b/src/storage/v3/result.hpp index c9c0c8a4b..b86ede6b4 100644 --- a/src/storage/v3/result.hpp +++ b/src/storage/v3/result.hpp @@ -12,6 +12,7 @@ #pragma once #include +#include #include #include #include @@ -24,10 +25,11 @@ namespace memgraph::storage::v3 { static_assert(std::is_same_v); struct ShardError { - ShardError(common::ErrorCode code, std::string message, std::string source) - : code{code}, message{std::move(message)}, source{std::move(source)} {} + ShardError(common::ErrorCode code, std::string message, const std::experimental::source_location location) + : code{code}, message{std::move(message)}, source{fmt::format("{}:{}", location.file_name(), location.line())} {} - ShardError(common::ErrorCode code, std::string source) : code{code}, source{std::move(source)} {} + ShardError(common::ErrorCode code, const std::experimental::source_location location) + : code{code}, source{fmt::format("{}:{}", location.file_name(), location.line())} {} common::ErrorCode code; // TODO Maybe add category @@ -38,7 +40,7 @@ struct ShardError { }; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define SHARD_ERROR(...) memgraph::storage::v3::ShardError(__VA_ARGS__, fmt::format("{}:{}", __FILE__, __LINE__)) +#define SHARD_ERROR(...) memgraph::storage::v3::ShardError(__VA_ARGS__, std::experimental::source_location::current()) template using ShardResult = utils::BasicResult;