From 06060dab7caa5fa8be2be3f2fb88fa64b97efec4 Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Tue, 15 Oct 2024 12:40:09 +0200 Subject: [PATCH] Fix exception in parse_ini_file() --- src/string_utils.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/string_utils.cpp b/src/string_utils.cpp index 4326923..04e5395 100644 --- a/src/string_utils.cpp +++ b/src/string_utils.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -82,7 +83,7 @@ map sc::parse_ini_file(const string& path, bool ignore_sections) string prefix; string line; ifstream file {path}; - file.exceptions(ios::badbit); // it seems that getline() will set failbit when confronted with eof immediately + if (!file) throw runtime_error {string {"could not open "} + path}; while (getline(file, line)) { if (line[0] == '#') continue; // ignore comments if (line[0] == '[') {