From ea4113e623170692a469f152752f9d583eecfedd Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Tue, 19 Mar 2019 14:30:53 -0400 Subject: removed exit errors in favor of throws --- lib/src/network.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/src/network.cpp b/lib/src/network.cpp index 43b0fab..1edc973 100644 --- a/lib/src/network.cpp +++ b/lib/src/network.cpp @@ -1,6 +1,22 @@ #include "network.hpp" +class nanException: public std::exception +{ + virtual const char* what() const throw() + { + return "The linear problem returned NaN."; + } +} nanex; + +class nofuseException: public std::exception +{ + virtual const char* what() const throw() + { + return "No valid fuse was available to break."; + } +} nofuseex; + network::network(const graph& G, cholmod_common *c) : c(c), G(G), fuses(G.edges.size(), false), thresholds(G.edges.size(), 1) { b = CHOL_F(zeros)(G.vertices.size(), 1, CHOLMOD_REAL, c); for (unsigned i = 0; i < G.edges.size(); i++) { @@ -166,7 +182,7 @@ current_info network::get_current_info() { cholmod_dense *x = CHOL_F(solve)(CHOLMOD_A, factor, b, c); if (((double *)x->x)[0] != ((double *)x->x)[0]) { - exit(2); + throw nanex; } cholmod_dense *y = CHOL_F(allocate_dense)(G.edges.size(), 1, G.edges.size(), CHOLMOD_REAL, c); @@ -231,7 +247,7 @@ void network::fracture(hooks& m, double cutoff) { } if (max_pos == UINT_MAX) { - exit(3); + throw nofuseex; } this->break_edge(max_pos); -- cgit v1.2.3-54-g00ecf