Extend the Error enum instead of a separate type
The error representing that a vertex is already inserted into the skip-list was represented by the struct AlreadyInseertedElement. Instead of using that struct, extend the memgraph::storage::v3::Error scoped enum and use that to represent the double-insertion error.
This commit is contained in:
parent
3d954e7abc
commit
39b40ecf00
@ -404,6 +404,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
|
||||
case Error::SERIALIZATION_ERROR:
|
||||
case Error::VERTEX_HAS_EDGES:
|
||||
case Error::PROPERTIES_DISABLED:
|
||||
case Error::VERTEX_ALREADY_INSERTED:
|
||||
throw ExpressionRuntimeException("Unexpected error when accessing labels.");
|
||||
}
|
||||
}
|
||||
@ -751,6 +752,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
|
||||
case Error::SERIALIZATION_ERROR:
|
||||
case Error::VERTEX_HAS_EDGES:
|
||||
case Error::PROPERTIES_DISABLED:
|
||||
case Error::VERTEX_ALREADY_INSERTED:
|
||||
throw ExpressionRuntimeException("Unexpected error when getting a property.");
|
||||
}
|
||||
}
|
||||
@ -779,6 +781,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
|
||||
case Error::SERIALIZATION_ERROR:
|
||||
case Error::VERTEX_HAS_EDGES:
|
||||
case Error::PROPERTIES_DISABLED:
|
||||
case Error::VERTEX_ALREADY_INSERTED:
|
||||
throw ExpressionRuntimeException("Unexpected error when getting a property.");
|
||||
}
|
||||
}
|
||||
|
@ -489,6 +489,7 @@ class BoltSession final : public memgraph::communication::bolt::Session<memgraph
|
||||
case memgraph::storage::v3::Error::VERTEX_HAS_EDGES:
|
||||
case memgraph::storage::v3::Error::PROPERTIES_DISABLED:
|
||||
case memgraph::storage::v3::Error::NONEXISTENT_OBJECT:
|
||||
case memgraph::storage::v3::Error::VERTEX_ALREADY_INSERTED:
|
||||
throw memgraph::communication::bolt::ClientError("Unexpected storage error when streaming summary.");
|
||||
}
|
||||
}
|
||||
@ -523,6 +524,7 @@ class BoltSession final : public memgraph::communication::bolt::Session<memgraph
|
||||
case memgraph::storage::v3::Error::VERTEX_HAS_EDGES:
|
||||
case memgraph::storage::v3::Error::SERIALIZATION_ERROR:
|
||||
case memgraph::storage::v3::Error::PROPERTIES_DISABLED:
|
||||
case memgraph::storage::v3::Error::VERTEX_ALREADY_INSERTED:
|
||||
throw memgraph::communication::bolt::ClientError("Unexpected storage error when streaming results.");
|
||||
}
|
||||
}
|
||||
|
@ -110,6 +110,8 @@ inline void HandleErrorOnPropertyUpdate(const storage::v3::Error error) {
|
||||
throw QueryRuntimeException("Can't set property because properties on edges are disabled.");
|
||||
case storage::v3::Error::VERTEX_HAS_EDGES:
|
||||
case storage::v3::Error::NONEXISTENT_OBJECT:
|
||||
case storage::v3::Error::VERTEX_ALREADY_INSERTED:
|
||||
|
||||
throw QueryRuntimeException("Unexpected error when setting a property.");
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ enum class Error : uint8_t {
|
||||
DELETED_OBJECT,
|
||||
VERTEX_HAS_EDGES,
|
||||
PROPERTIES_DISABLED,
|
||||
VERTEX_ALREADY_INSERTED
|
||||
};
|
||||
|
||||
template <class TValue>
|
||||
|
@ -363,7 +363,7 @@ ShardOperationResult<VertexAccessor> Shard::Accessor::CreateVertexAndValidate(
|
||||
|
||||
VertexAccessor vertex_acc{&it->vertex, transaction_, &shard_->indices_, config_, shard_->vertex_validator_};
|
||||
if (!inserted) {
|
||||
return {AlreadyInsertedElement{}};
|
||||
return {Error::VERTEX_ALREADY_INSERTED};
|
||||
}
|
||||
MG_ASSERT(it != acc.end(), "Invalid Vertex accessor!");
|
||||
|
||||
|
@ -18,9 +18,7 @@
|
||||
|
||||
namespace memgraph::storage::v3 {
|
||||
|
||||
struct AlreadyInsertedElement {};
|
||||
|
||||
using ResultErrorType = std::variant<SchemaViolation, AlreadyInsertedElement, Error>;
|
||||
using ResultErrorType = std::variant<SchemaViolation, Error>;
|
||||
|
||||
template <typename TValue>
|
||||
using ShardOperationResult = utils::BasicResult<ResultErrorType, TValue>;
|
||||
|
@ -492,14 +492,31 @@ msgs::WriteResponses ShardRsm::ApplyWrite(msgs::CreateVerticesRequest &&req) {
|
||||
auto &error = result_schema.GetError();
|
||||
|
||||
std::visit(
|
||||
[]<typename T>(T &&) {
|
||||
[]<typename T>(T &&error) {
|
||||
using ErrorType = std::remove_cvref_t<T>;
|
||||
if constexpr (std::is_same_v<ErrorType, SchemaViolation>) {
|
||||
spdlog::debug("Creating vertex failed with error: SchemaViolation");
|
||||
} else if constexpr (std::is_same_v<ErrorType, Error>) {
|
||||
spdlog::debug("Creating vertex failed with error: Error");
|
||||
} else if constexpr (std::is_same_v<ErrorType, AlreadyInsertedElement>) {
|
||||
spdlog::debug("Updating vertex failed with error: AlreadyInsertedElement");
|
||||
switch (error) {
|
||||
case Error::DELETED_OBJECT:
|
||||
spdlog::debug("Creating vertex failed with error: DELETED_OBJECT");
|
||||
break;
|
||||
case Error::NONEXISTENT_OBJECT:
|
||||
spdlog::debug("Creating vertex failed with error: NONEXISTENT_OBJECT");
|
||||
break;
|
||||
case Error::SERIALIZATION_ERROR:
|
||||
spdlog::debug("Creating vertex failed with error: SERIALIZATION_ERROR");
|
||||
break;
|
||||
case Error::PROPERTIES_DISABLED:
|
||||
spdlog::debug("Creating vertex failed with error: PROPERTIES_DISABLED");
|
||||
break;
|
||||
case Error::VERTEX_HAS_EDGES:
|
||||
spdlog::debug("Creating vertex failed with error: VERTEX_HAS_EDGES");
|
||||
break;
|
||||
case Error::VERTEX_ALREADY_INSERTED:
|
||||
spdlog::debug("Creating vertex failed with error: VERTEX_ALREADY_INSERTED");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
static_assert(kAlwaysFalse<T>, "Missing type from variant visitor");
|
||||
}
|
||||
@ -539,14 +556,31 @@ msgs::WriteResponses ShardRsm::ApplyWrite(msgs::UpdateVerticesRequest &&req) {
|
||||
auto &error = result_schema.GetError();
|
||||
|
||||
std::visit(
|
||||
[]<typename T>(T &&) {
|
||||
[]<typename T>(T &&error) {
|
||||
using ErrorType = std::remove_cvref_t<T>;
|
||||
if constexpr (std::is_same_v<ErrorType, SchemaViolation>) {
|
||||
spdlog::debug("Updating vertex failed with error: SchemaViolation");
|
||||
} else if constexpr (std::is_same_v<ErrorType, Error>) {
|
||||
spdlog::debug("Updating vertex failed with error: Error");
|
||||
} else if constexpr (std::is_same_v<ErrorType, AlreadyInsertedElement>) {
|
||||
spdlog::debug("Updating vertex failed with error: AlreadyInsertedElement");
|
||||
switch (error) {
|
||||
case Error::DELETED_OBJECT:
|
||||
spdlog::debug("Updating vertex failed with error: DELETED_OBJECT");
|
||||
break;
|
||||
case Error::NONEXISTENT_OBJECT:
|
||||
spdlog::debug("Updating vertex failed with error: NONEXISTENT_OBJECT");
|
||||
break;
|
||||
case Error::SERIALIZATION_ERROR:
|
||||
spdlog::debug("Updating vertex failed with error: SERIALIZATION_ERROR");
|
||||
break;
|
||||
case Error::PROPERTIES_DISABLED:
|
||||
spdlog::debug("Updating vertex failed with error: PROPERTIES_DISABLED");
|
||||
break;
|
||||
case Error::VERTEX_HAS_EDGES:
|
||||
spdlog::debug("Updating vertex failed with error: VERTEX_HAS_EDGES");
|
||||
break;
|
||||
case Error::VERTEX_ALREADY_INSERTED:
|
||||
spdlog::debug("Updating vertex failed with error: VERTEX_ALREADY_INSERTED");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
static_assert(kAlwaysFalse<T>, "Missing type from variant visitor");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user