diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-03-19 14:30:53 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-03-19 14:30:53 -0400 |
commit | ea4113e623170692a469f152752f9d583eecfedd (patch) | |
tree | 8bcf79dc7dfc005f682997c2a5a260270f5a3b4c /lib/src | |
parent | aad91479b4e32ca090d7cf36e5b3b30d5458a7f4 (diff) | |
download | fuse_networks-ea4113e623170692a469f152752f9d583eecfedd.tar.gz fuse_networks-ea4113e623170692a469f152752f9d583eecfedd.tar.bz2 fuse_networks-ea4113e623170692a469f152752f9d583eecfedd.zip |
removed exit errors in favor of throws
Diffstat (limited to 'lib/src')
-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); |