From 98c57b6117c7cab26954d456230cfd5a70442104 Mon Sep 17 00:00:00 2001
From: Ian Bell <ian.bell@nist.gov>
Date: Thu, 20 May 2021 14:11:31 -0400
Subject: [PATCH] More useful message if JSON path is invalid to fluid file

---
 include/teqp/models/multifluid.hpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/teqp/models/multifluid.hpp b/include/teqp/models/multifluid.hpp
index cf83571..9cd7a8b 100644
--- a/include/teqp/models/multifluid.hpp
+++ b/include/teqp/models/multifluid.hpp
@@ -219,7 +219,12 @@ public:
         using namespace nlohmann;
         auto i = 0;
         for (auto& c : components) {
-            auto j = json::parse(std::ifstream(coolprop_root + "/dev/fluids/" + c + ".json"));
+            std::string path = coolprop_root + "/dev/fluids/" + c + ".json";
+            std::ifstream ifs(path);
+            if (!ifs) {
+                throw std::invalid_argument("Load path is invalid: " + path);
+            }
+            auto j = json::parse(ifs);
             auto red = j["EOS"][0]["STATES"]["reducing"];
             double Tc_ = red["T"];
             double rhoc_ = red["rhomolar"];
-- 
GitLab