summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2019-03-19 14:30:53 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2019-03-19 14:30:53 -0400
commitea4113e623170692a469f152752f9d583eecfedd (patch)
tree8bcf79dc7dfc005f682997c2a5a260270f5a3b4c /lib
parentaad91479b4e32ca090d7cf36e5b3b30d5458a7f4 (diff)
downloadfuse_networks-ea4113e623170692a469f152752f9d583eecfedd.tar.gz
fuse_networks-ea4113e623170692a469f152752f9d583eecfedd.tar.bz2
fuse_networks-ea4113e623170692a469f152752f9d583eecfedd.zip
removed exit errors in favor of throws
Diffstat (limited to 'lib')
-rw-r--r--lib/src/network.cpp20
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);