Skip to content
Snippets Groups Projects
Commit f7bc43b6 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[BL] ConfigTree: Fix warning "catch by value".

parent 39475462
No related branches found
No related tags found
No related merge requests found
...@@ -120,14 +120,20 @@ peekConfigParameter(std::string const& param) const ...@@ -120,14 +120,20 @@ peekConfigParameter(std::string const& param) const
{ {
checkKeyname(param); checkKeyname(param);
if (auto p =_tree->get_child_optional(param)) { if (auto p = _tree->get_child_optional(param))
try { {
try
{
return p->get_value<T>(); return p->get_value<T>();
} catch (boost::property_tree::ptree_bad_data) {
error("Value for key <" + param + "> `" + shortString(p->data())
+ "' not convertible to the desired type.");
} }
} else { catch (boost::property_tree::ptree_bad_data const&)
{
error("Value for key <" + param + "> `" + shortString(p->data()) +
"' not convertible to the desired type.");
}
}
else
{
error("Key <" + param + "> has not been found"); error("Key <" + param + "> has not been found");
} }
} }
......
...@@ -54,13 +54,16 @@ makeConfigTree(const std::string& filepath, const bool be_ruthless, ...@@ -54,13 +54,16 @@ makeConfigTree(const std::string& filepath, const bool be_ruthless,
// note: Trimming whitespace and ignoring comments is crucial in order // note: Trimming whitespace and ignoring comments is crucial in order
// for our configuration tree implementation to work! // for our configuration tree implementation to work!
try { try
{
read_xml(filepath, ptree, read_xml(filepath, ptree,
boost::property_tree::xml_parser::no_comments | boost::property_tree::xml_parser::no_comments |
boost::property_tree::xml_parser::trim_whitespace); boost::property_tree::xml_parser::trim_whitespace);
} catch (boost::property_tree::xml_parser_error e) { }
catch (boost::property_tree::xml_parser_error const& e)
{
OGS_FATAL("Error while parsing XML file `%s' at line %lu: %s.", OGS_FATAL("Error while parsing XML file `%s' at line %lu: %s.",
e.filename().c_str(), e.line(), e.message().c_str()); e.filename().c_str(), e.line(), e.message().c_str());
} }
DBUG("Project configuration from file \'%s\' read.", filepath.c_str()); DBUG("Project configuration from file \'%s\' read.", filepath.c_str());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment