[mlpack-git] master: Don't call exit(1); throw an exception. That was a bad decision, and I'm sorry, and I promise that I've learned my lesson. (6dd7d3e)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Wed Apr 8 14:39:06 EDT 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/9e3dd12b006474df53565386201dbc076a851438...6dd7d3e90151026d6da3c9178b009ea1a10c91d5

>---------------------------------------------------------------

commit 6dd7d3e90151026d6da3c9178b009ea1a10c91d5
Author: ryan <ryan at ratml.org>
Date:   Wed Apr 8 14:37:00 2015 -0400

    Don't call exit(1); throw an exception.
    That was a bad decision, and I'm sorry, and I promise that I've learned my lesson.


>---------------------------------------------------------------

6dd7d3e90151026d6da3c9178b009ea1a10c91d5
 src/mlpack/core/util/prefixedoutstream_impl.hpp | 4 ++--
 src/mlpack/prereqs.hpp                          | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mlpack/core/util/prefixedoutstream_impl.hpp b/src/mlpack/core/util/prefixedoutstream_impl.hpp
index cbadfda..e90d766 100644
--- a/src/mlpack/core/util/prefixedoutstream_impl.hpp
+++ b/src/mlpack/core/util/prefixedoutstream_impl.hpp
@@ -73,7 +73,7 @@ void PrefixedOutStream::BaseLogic(const T& val)
   std::ostringstream convert;
   convert << val;
 
-  if(convert.fail())
+  if (convert.fail())
   {
     PrefixIfNeeded();
     if (!ignoreInput)
@@ -130,7 +130,7 @@ void PrefixedOutStream::BaseLogic(const T& val)
 
   // If we displayed a newline and we need to terminate afterwards, do that.
   if (fatal && newlined)
-    exit(1);
+    throw std::runtime_error("fatal error; see Log::Fatal output");
 }
 
 // This is an inline function (that is why it is here and not in .cc).
diff --git a/src/mlpack/prereqs.hpp b/src/mlpack/prereqs.hpp
index 21b726f..a838a89 100644
--- a/src/mlpack/prereqs.hpp
+++ b/src/mlpack/prereqs.hpp
@@ -22,6 +22,7 @@
 #include <float.h>
 #include <stdint.h>
 #include <iostream>
+#include <stdexcept>
 
 // Defining _USE_MATH_DEFINES should set M_PI.
 #define _USE_MATH_DEFINES



More information about the mlpack-git mailing list