File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ AstExpr ParseQuery(std::string_view query) {
20
20
QueryDriver driver{};
21
21
driver.ResetScanner ();
22
22
driver.SetInput (std::string{query});
23
- (void )Parser (&driver)(); // throws
23
+ (void )Parser (&driver)(); // can throw
24
24
return driver.Take ();
25
25
}
26
26
@@ -82,8 +82,12 @@ SearchAlgorithm::~SearchAlgorithm() = default;
82
82
bool SearchAlgorithm::Init (string_view query) {
83
83
try {
84
84
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 ;
86
89
} catch (...) {
90
+ LOG (INFO) << " Unexpected query parser error" ;
87
91
return false ;
88
92
}
89
93
}
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ class SearchParserTest : public ::testing::Test {
36
36
37
37
void ParseExpr (const std::string& str) {
38
38
raw_expr_ = str;
39
- search_algo_.Init (str);
39
+ CHECK ( search_algo_.Init (str) );
40
40
}
41
41
42
42
bool Check (DocumentAccessor* doc) const {
You can’t perform that action at this time.
0 commit comments