throw specific error if json file does not exist

This commit is contained in:
Franz Georg Fuchs
2021-02-24 10:39:56 +01:00
parent a5c5dc2ec9
commit 17126ba229

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);