[ck2cti] Improve error message when failing to parse a reaction

Show the original reaction expression rather than the one where all
recognized tokens have already been replaced.
This commit is contained in:
Ray Speth 2017-08-22 00:06:22 -04:00
parent 739d4e4830
commit 4b5a37a336

View file

@ -1178,6 +1178,7 @@ class Parser(object):
b = float(tokens[-2])
Ea = float(tokens[-1])
reaction = ''.join(tokens[:-3]) + '\n'
original_reaction = reaction # for use in error messages
# Identify tokens in the reaction expression in order of
# decreasing length
@ -1207,7 +1208,7 @@ class Parser(object):
try:
locs[j] = float(token), 'coeff'
except ValueError:
raise InputParseError('Unexpected token "{0}" in reaction expression "{1}".'.format(token, reaction))
raise InputParseError('Unexpected token "{0}" in reaction expression "{1}".'.format(token, original_reaction))
reactants = []
products = []