From daaee30be843d3d764f7613c6f72bab5a782ba23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sat, 4 Nov 2023 19:06:12 +0100 Subject: [PATCH] throw error when input file cannot be opened --- example.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/example.cpp b/example.cpp index 07bb12a..62a8292 100644 --- a/example.cpp +++ b/example.cpp @@ -13,6 +13,9 @@ int main(int argc, char** argv) } std::fstream input_file_graph{argv[1]}; + if (not input_file_graph.is_open()) { + throw std::runtime_error(std::string("Could not open file for reading: ") + argv[1]); + } ED::Graph const graph = ED::Graph::read_dimacs(input_file_graph); ED::Graph greedy_matching_as_graph{graph.num_nodes()};