Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2013-04-01 14:05:55 +0400
committerKenneth Heafield <github@kheafield.com>2013-04-01 14:05:55 +0400
commitb144e48fcc5c84b24595899ec53eae5dc4bf2428 (patch)
tree0bab838de9496f1c8bec3141ff5331ef2006fe4b /moses/Util.cpp
parent627f3f908cbc4a1dc4c5970a13b45bd5fcc66f82 (diff)
Make failure to parse a boolean argument fatal instead of log + interpret as false.
Diffstat (limited to 'moses/Util.cpp')
-rw-r--r--moses/Util.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/moses/Util.cpp b/moses/Util.cpp
index 98de1241e..495e05124 100644
--- a/moses/Util.cpp
+++ b/moses/Util.cpp
@@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "TypeDef.h"
#include "Util.h"
#include "Timer.h"
+#include "util/exception.hh"
#include "util/file.hh"
using namespace std;
@@ -65,6 +66,8 @@ const std::string ToLower(const std::string& str)
return lc;
}
+class BoolValueException : public util::Exception {};
+
template<>
bool Scan<bool>(const std::string &input)
{
@@ -73,8 +76,7 @@ bool Scan<bool>(const std::string &input)
return true;
if (lc == "no" || lc == "n" || lc =="false" || lc == "0")
return false;
- TRACE_ERR( "Scan<bool>: didn't understand '" << lc << "', returning false" << std::endl);
- return false;
+ UTIL_THROW(BoolValueException, "Could not interpret " << input << " as a boolean. After lowercasing, valid values are yes, y, true, 1, no, n, false, and 0.");
}
bool FileExists(const std::string& filePath)