diff --git a/BaseLib/ConfigTree-impl.h b/BaseLib/ConfigTree-impl.h index 39f8eba02152b13e575074397831a5e067f4cf73..4256d180a8df156e7ec1fe161550a106091dec49 100644 --- a/BaseLib/ConfigTree-impl.h +++ b/BaseLib/ConfigTree-impl.h @@ -120,14 +120,20 @@ peekConfigParameter(std::string const& param) const { checkKeyname(param); - if (auto p =_tree->get_child_optional(param)) { - try { + if (auto p = _tree->get_child_optional(param)) + { + try + { 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"); } } diff --git a/BaseLib/ConfigTreeUtil.cpp b/BaseLib/ConfigTreeUtil.cpp index d6f0c74e5edba98d827db14f2c995ef093ae2be8..e64f8ae4dbc6b7be1b0d02ad4b5ead3c63b951fa 100644 --- a/BaseLib/ConfigTreeUtil.cpp +++ b/BaseLib/ConfigTreeUtil.cpp @@ -54,13 +54,16 @@ makeConfigTree(const std::string& filepath, const bool be_ruthless, // note: Trimming whitespace and ignoring comments is crucial in order // for our configuration tree implementation to work! - try { + try + { read_xml(filepath, ptree, boost::property_tree::xml_parser::no_comments | - boost::property_tree::xml_parser::trim_whitespace); - } catch (boost::property_tree::xml_parser_error e) { + boost::property_tree::xml_parser::trim_whitespace); + } + catch (boost::property_tree::xml_parser_error const& e) + { 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());