Skip to content

Commit 63344a8

Browse files
committed
fix: error fixes
Signed-off-by: Vladislav Oleshko <[email protected]>
1 parent dc2f1a4 commit 63344a8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/core/search/search.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ AstExpr ParseQuery(std::string_view query) {
2020
QueryDriver driver{};
2121
driver.ResetScanner();
2222
driver.SetInput(std::string{query});
23-
(void)Parser (&driver)(); // throws
23+
(void)Parser (&driver)(); // can throw
2424
return driver.Take();
2525
}
2626

@@ -82,8 +82,12 @@ SearchAlgorithm::~SearchAlgorithm() = default;
8282
bool SearchAlgorithm::Init(string_view query) {
8383
try {
8484
query_ = make_unique<AstExpr>(ParseQuery(query));
85-
return true;
85+
return !holds_alternative<monostate>(*query_);
86+
} catch (const Parser::syntax_error& se) {
87+
LOG(INFO) << "Failed to parse query \"" << query << "\":" << se.what();
88+
return false;
8689
} catch (...) {
90+
LOG(INFO) << "Unexpected query parser error";
8791
return false;
8892
}
8993
}

src/core/search/search_parser_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SearchParserTest : public ::testing::Test {
3636

3737
void ParseExpr(const std::string& str) {
3838
raw_expr_ = str;
39-
search_algo_.Init(str);
39+
CHECK(search_algo_.Init(str));
4040
}
4141

4242
bool Check(DocumentAccessor* doc) const {

0 commit comments

Comments
 (0)