From 4ade4945a0bb89bebf66da7d3a36ec9aa4a343bc Mon Sep 17 00:00:00 2001 From: Tiago Gomes Date: Mon, 7 May 2012 17:52:47 +0100 Subject: [PATCH] improve Util::abort --- packages/CLPBN/clpbn/bp/Util.cpp | 12 ++++++------ packages/CLPBN/clpbn/bp/Util.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/CLPBN/clpbn/bp/Util.cpp b/packages/CLPBN/clpbn/bp/Util.cpp index 80b0dd755..6eb220779 100644 --- a/packages/CLPBN/clpbn/bp/Util.cpp +++ b/packages/CLPBN/clpbn/bp/Util.cpp @@ -55,9 +55,7 @@ stringToUnsigned (string str) stringstream ss; ss << str; ss >> val; - if (val < 0) { - abort ("error: the value tried to read is negative"); - } + abort ("error: the value tried to read is negative", val < 0); return static_cast (val); } @@ -297,10 +295,12 @@ setHorusFlag (string key, string value) void -abort (string msg) +abort (string msg, bool b) { - cerr << msg << endl; - std::abort(); + if (b) { + cerr << msg << endl; + std::abort(); + } } diff --git a/packages/CLPBN/clpbn/bp/Util.h b/packages/CLPBN/clpbn/bp/Util.h index 92d95681f..72517fb6b 100644 --- a/packages/CLPBN/clpbn/bp/Util.h +++ b/packages/CLPBN/clpbn/bp/Util.h @@ -78,7 +78,7 @@ vector getStateLines (const Vars&); bool setHorusFlag (string key, string value); -void abort (string msg); +void abort (string msg, bool = true); void printHeader (string, std::ostream& os = std::cout);