Use experimental source location
This commit is contained in:
parent
ec4804b72a
commit
bffef1a653
@ -100,7 +100,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
|
||||
#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<TypedValue> {
|
||||
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<TypedValue> {
|
||||
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<TypedValue> {
|
||||
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);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <experimental/source_location>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
@ -24,10 +25,11 @@ namespace memgraph::storage::v3 {
|
||||
static_assert(std::is_same_v<uint8_t, unsigned char>);
|
||||
|
||||
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 <class TValue>
|
||||
using ShardResult = utils::BasicResult<ShardError, TValue>;
|
||||
|
Loading…
Reference in New Issue
Block a user