diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/src/network.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
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); |