better exception when boost regex cannot initialize ICU support - closes #2722
This commit is contained in:
parent
87e9c64fc4
commit
7f597233c9
1 changed files with 17 additions and 6 deletions
|
@ -40,18 +40,29 @@ expression_ptr parse_expression(std::string const& str)
|
||||||
auto node = std::make_shared<expr_node>();
|
auto node = std::make_shared<expr_node>();
|
||||||
std::string::const_iterator itr = str.begin();
|
std::string::const_iterator itr = str.begin();
|
||||||
std::string::const_iterator end = str.end();
|
std::string::const_iterator end = str.end();
|
||||||
try {
|
bool r = false;
|
||||||
bool r = boost::spirit::qi::phrase_parse(itr, end, g, space, *node);
|
try
|
||||||
if (r && itr == end)
|
{
|
||||||
|
r = boost::spirit::qi::phrase_parse(itr, end, g, space, *node);
|
||||||
|
}
|
||||||
|
catch (std::exception const& ex)
|
||||||
|
{
|
||||||
|
if (std::string("boost::spirit::qi::expectation_failure") == std::string(ex.what()))
|
||||||
{
|
{
|
||||||
return node;
|
// no need to show "boost::spirit::qi::expectation_failure" which is a std::runtime_error
|
||||||
|
throw config_error("Failed to parse expression: \"" + str + "\"");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw config_error("Failed to parse expression: \"" + str + "\"");
|
// show "Could not initialize ICU resources" from boost::regex which is a std::runtime_error
|
||||||
|
throw config_error(std::string(ex.what()) + " for expression: \"" + str + "\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception const&) // boost::spirit::qi::expectation_failure
|
if (r && itr == end)
|
||||||
|
{
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
throw config_error("Failed to parse expression: \"" + str + "\"");
|
throw config_error("Failed to parse expression: \"" + str + "\"");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue