From 16c352c6af28794c75ed814463c5afe85c70ecb2 Mon Sep 17 00:00:00 2001 From: Albert S Date: Sun, 27 Mar 2022 19:47:52 +0200 Subject: [PATCH] utils: readCompleteFile(): Throw exception if file can't be opened --- utils.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils.cpp b/utils.cpp index c6db75a..8201c43 100644 --- a/utils.cpp +++ b/utils.cpp @@ -138,6 +138,10 @@ std::string utils::readCompleteFile(std::string_view filepath) { std::fstream stream(std::string{filepath}); + if(!stream.is_open()) + { + throw std::runtime_error("stream is not open"); + } std::stringstream ss; ss << stream.rdbuf(); std::string content = ss.str();