From 4e34f975cb2d93408f5bdafbb1e4ecdf86bc5b96 Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Mon, 13 Apr 2020 17:30:44 +0200
Subject: [PATCH] [io][container] Throw error if file couldn't be opened

---
 dumux/io/container.hh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/dumux/io/container.hh b/dumux/io/container.hh
index fe4af83274..7b60883ef1 100644
--- a/dumux/io/container.hh
+++ b/dumux/io/container.hh
@@ -33,6 +33,8 @@
 #include <fstream>
 #include <iterator>
 
+#include <dune/common/exceptions.hh>
+
 namespace Dumux {
 
 /*!
@@ -80,6 +82,8 @@ template<typename Container>
 Container readFileToContainer(const std::string& filename)
 {
     std::ifstream infile(filename, std::ios::in);
+    if (!infile)
+        DUNE_THROW(Dune::IOError, "Could not open file: " << filename);
     return readStreamToContainer<Container>(infile);
 }
 
-- 
GitLab