Don't throw then immediately catch and rethrow

This commit is contained in:
Oliver Hamlet
2016-12-14 22:22:24 +00:00
parent a3d65f020a
commit cf4f7252ec
+11 -14
View File
@@ -77,26 +77,23 @@ bool ConditionalMetadata::ParseCondition(Game * game) const {
ConditionGrammar<string::const_iterator, boost::spirit::qi::space_type> grammar(game);
boost::spirit::qi::space_type skipper;
string::const_iterator begin, end;
begin = condition_.begin();
end = condition_.end();
string::const_iterator begin = condition_.begin();
string::const_iterator end = condition_.end();
bool parseResult;
bool evaluation;
try {
bool evaluation;
bool parseResult = boost::spirit::qi::phrase_parse(begin, end, grammar, skipper, evaluation);
if (!parseResult || begin != end) {
BOOST_LOG_TRIVIAL(error) << "Failed to parse condition \"" << condition_ << "\": only partially matched expected syntax.";
throw ConditionSyntaxError((boost::format(translate("Failed to parse condition \"%1%\": only partially matched expected syntax.")) % condition_).str());
}
return evaluation;
} catch (ConditionSyntaxError& e) {
throw;
} catch (exception& e) {
BOOST_LOG_TRIVIAL(error) << "Failed to evaluate condition \"" << condition_ << "\": " << e.what();
throw;
}
if (!parseResult || begin != end) {
BOOST_LOG_TRIVIAL(error) << "Failed to parse condition \"" << condition_ << "\": only partially matched expected syntax.";
throw ConditionSyntaxError((boost::format(translate("Failed to parse condition \"%1%\": only partially matched expected syntax.")) % condition_).str());
}
return evaluation;
}
}