diff options
author | cjamin <cjamin@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-06-09 10:42:12 +0000 |
---|---|---|
committer | cjamin <cjamin@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-06-09 10:42:12 +0000 |
commit | 4918b9c752a2d269678791dc4772ae9276539051 (patch) | |
tree | b73af020f63c9c12bd00f74e126fa4856f58d890 | |
parent | 2ceede5cd9f226e66bb1ecbe1798330c349c2aa0 (diff) |
Throw exceptions if file not found
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2533 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: b412f432aeac6aef07ac2d9d65d50dc8f508c2e6
-rw-r--r-- | src/common/include/gudhi/reader_utils.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 62b479ac..35af09bd 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -94,7 +94,10 @@ template< typename Graph_t, typename Filtration_value, typename Vertex_handle > Graph_t read_graph(std::string file_name) { std::ifstream in_(file_name.c_str(), std::ios::in); if (!in_.is_open()) { - std::cerr << "Unable to open file " << file_name << std::endl; + std::string error_str("read_graph - Unable to open file "); + error_str.append(file_name); + std::cerr << error_str << std::endl; + throw std::invalid_argument(error_str); } typedef std::pair< Vertex_handle, Vertex_handle > Edge_t; @@ -308,10 +311,10 @@ void read_persistence_intervals_and_dimension(std::string const& filename, Outpu std::ifstream in(filename); if (!in.is_open()) { -#ifdef DEBUG_TRACES - std::cerr << "File \"" << filename << "\" does not exist.\n"; -#endif // DEBUG_TRACES - return; + std::string error_str("read_persistence_intervals_and_dimension - Unable to open file "); + error_str.append(filename); + std::cerr << error_str << std::endl; + throw std::invalid_argument(error_str); } while (!in.eof()) { |