Add more error handling

This commit is contained in:
Ante Pušić 2024-02-04 12:33:37 +01:00
parent 9e0b857e25
commit a919429ea5
2 changed files with 7 additions and 14 deletions

View File

@ -2453,7 +2453,7 @@ PreparedQuery PrepareIndexQuery(ParsedQuery parsed_query, bool in_explicit_trans
maybe_index_error = properties.empty() ? dba->CreateIndex(label) : dba->CreateIndex(label, properties[0]);
} else if (index_type == IndexQuery::Type::TEXT) {
if (!flags::run_time::GetTextSearchEnabled()) {
// TODO antepusic throw exception
throw QueryException("To use text indices, enable the text search feature.");
}
maybe_index_error = dba->CreateTextIndex(index_name, label);
}
@ -2483,7 +2483,7 @@ PreparedQuery PrepareIndexQuery(ParsedQuery parsed_query, bool in_explicit_trans
maybe_index_error = properties.empty() ? dba->DropIndex(label) : dba->DropIndex(label, properties[0]);
} else if (index_type == IndexQuery::Type::TEXT) {
if (!flags::run_time::GetTextSearchEnabled()) {
// TODO antepusic throw exception
throw QueryException("To use text indices, enable the text search feature.");
}
maybe_index_error = dba->DropTextIndex(index_name);
}

View File

@ -3334,18 +3334,11 @@ mgp_error mgp_graph_delete_edge(struct mgp_graph *graph, mgp_edge *edge) {
mgp_error mgp_graph_has_text_index(mgp_graph *graph, const char *index_name, int *result) {
return WrapExceptions([graph, index_name, result]() {
std::visit(memgraph::utils::Overloaded{[&](memgraph::query::DbAccessor *impl) {
if (!memgraph::flags::run_time::GetTextSearchEnabled()) {
// TODO antepusic throw exception
}
*result = impl->TextIndexExists(index_name);
},
[&](memgraph::query::SubgraphDbAccessor *impl) {
if (!memgraph::flags::run_time::GetTextSearchEnabled()) {
// TODO antepusic throw exception
}
*result = impl->GetAccessor()->TextIndexExists(index_name);
}},
std::visit(memgraph::utils::Overloaded{
[&](memgraph::query::DbAccessor *impl) { *result = impl->TextIndexExists(index_name); },
[&](memgraph::query::SubgraphDbAccessor *impl) {
*result = impl->GetAccessor()->TextIndexExists(index_name);
}},
graph->impl);
});
}