Skip to content

Commit 7f59723

Browse files
author
Dane Springmeyer
committed
better exception when boost regex cannot initialize ICU support - closes mapnik#2722
1 parent 87e9c64 commit 7f59723

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/expression.cpp

+17-6
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,29 @@ expression_ptr parse_expression(std::string const& str)
4040
auto node = std::make_shared<expr_node>();
4141
std::string::const_iterator itr = str.begin();
4242
std::string::const_iterator end = str.end();
43-
try {
44-
bool r = boost::spirit::qi::phrase_parse(itr, end, g, space, *node);
45-
if (r && itr == end)
43+
bool r = false;
44+
try
45+
{
46+
r = boost::spirit::qi::phrase_parse(itr, end, g, space, *node);
47+
}
48+
catch (std::exception const& ex)
49+
{
50+
if (std::string("boost::spirit::qi::expectation_failure") == std::string(ex.what()))
4651
{
47-
return node;
52+
// no need to show "boost::spirit::qi::expectation_failure" which is a std::runtime_error
53+
throw config_error("Failed to parse expression: \"" + str + "\"");
4854
}
4955
else
5056
{
51-
throw config_error("Failed to parse expression: \"" + str + "\"");
57+
// show "Could not initialize ICU resources" from boost::regex which is a std::runtime_error
58+
throw config_error(std::string(ex.what()) + " for expression: \"" + str + "\"");
5259
}
5360
}
54-
catch (std::exception const&) // boost::spirit::qi::expectation_failure
61+
if (r && itr == end)
62+
{
63+
return node;
64+
}
65+
else
5566
{
5667
throw config_error("Failed to parse expression: \"" + str + "\"");
5768
}

0 commit comments

Comments
 (0)