Merge pull request #3078 from fgfuchs/json_file_does_not_exist

throw specific error if json file does not exist
This commit is contained in:
Atgeirr Flø Rasmussen 2021-02-24 14:13:14 +01:00 committed by GitHub
commit 831f1db872
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,8 @@
#include <boost/version.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <opm/common/utility/FileSystem.hpp>
namespace Opm
{
@ -39,6 +41,9 @@ setupPropertyTree(FlowLinearSolverParameters p) // Note: copying the parameters
// Get configuration from file.
if (conf.size() > 5 && conf.substr(conf.size() - 5, 5) == ".json") { // the ends_with() method is not available until C++20
#if BOOST_VERSION / 100 % 1000 > 48
if ( !Opm::filesystem::exists(conf) ) {
OPM_THROW(std::invalid_argument, "JSON file " << conf << " does not exist.");
}
try {
boost::property_tree::ptree prm;
boost::property_tree::read_json(conf, prm);