From 8eb16634c14e7c85c61383c1e3283878bfbeb0a9 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Wed, 14 Feb 2018 22:53:39 +0100 Subject: [PATCH] Better error message in ValueParser --- src/storm/parser/ValueParser.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/storm/parser/ValueParser.cpp b/src/storm/parser/ValueParser.cpp index 90ccd4aff..96ed0015b 100644 --- a/src/storm/parser/ValueParser.cpp +++ b/src/storm/parser/ValueParser.cpp @@ -1,6 +1,7 @@ #include "storm/parser/ValueParser.h" #include "storm/exceptions/NotSupportedException.h" +#include "storm/exceptions/WrongFormatException.h" namespace storm { namespace parser { @@ -12,7 +13,6 @@ namespace storm { template<> void ValueParser::addParameter(std::string const& parameter) { - //STORM_LOG_THROW((std::is_same::value), storm::exceptions::NotSupportedException, "Parameters only allowed when using rational functions."); storm::expressions::Variable var = manager->declareRationalVariable(parameter); identifierMapping.emplace(var.getName(), var); parser.setIdentifierMapping(identifierMapping); @@ -21,7 +21,12 @@ namespace storm { template<> double ValueParser::parseValue(std::string const& value) const { - return boost::lexical_cast(value); + try { + return boost::lexical_cast(value); + } + catch(boost::bad_lexical_cast &) { + STORM_LOG_THROW(false, storm::exceptions::WrongFormatException, "Could not parse value '" << value << "'."); + } } template<>