From 8b2e06c6ee4fffbe9459594f7304b32f20f56b57 Mon Sep 17 00:00:00 2001 From: Ian Bell <ian.bell@nist.gov> Date: Wed, 20 Oct 2021 16:29:25 -0400 Subject: [PATCH] Stop early if bad BIP path is provided --- include/teqp/models/multifluid.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/teqp/models/multifluid.hpp b/include/teqp/models/multifluid.hpp index f987a2e..f19095d 100644 --- a/include/teqp/models/multifluid.hpp +++ b/include/teqp/models/multifluid.hpp @@ -797,7 +797,11 @@ inline auto get_EOSs(const std::string& coolprop_root, const std::vector<std::st inline auto build_multifluid_model(const std::vector<std::string>& components, const std::string& coolprop_root, const std::string& BIPcollectionpath, const nlohmann::json& flags = {}) { - const auto BIPcollection = nlohmann::json::parse(std::ifstream(BIPcollectionpath)); + auto stream = std::ifstream(BIPcollectionpath); + if (!stream) { + throw std::invalid_argument("Cannot open BIP collection file: " + BIPcollectionpath); + } + const auto BIPcollection = nlohmann::json::parse(stream); // Pure fluids auto [Tc, vc] = MultiFluidReducingFunction::get_Tcvc(coolprop_root, components); -- GitLab