[ck2cti] Improve error messages for invalid reaction entries
Print the full text of the problematic reaction entry Print the underlying exception message ahead of the traceback
This commit is contained in:
parent
c1d721dc94
commit
4f4a2bd071
1 changed files with 11 additions and 9 deletions
|
|
@ -1832,7 +1832,7 @@ class Parser(object):
|
||||||
break
|
break
|
||||||
|
|
||||||
lineStartsWithComment = not line and comment
|
lineStartsWithComment = not line and comment
|
||||||
line = line.strip()
|
line = line.rstrip()
|
||||||
comment = comment.rstrip()
|
comment = comment.rstrip()
|
||||||
|
|
||||||
if '=' in line and not lineStartsWithComment:
|
if '=' in line and not lineStartsWithComment:
|
||||||
|
|
@ -1843,7 +1843,7 @@ class Parser(object):
|
||||||
kinetics = ''
|
kinetics = ''
|
||||||
comments = ''
|
comments = ''
|
||||||
|
|
||||||
if line:
|
if line.strip():
|
||||||
kinetics += line + '\n'
|
kinetics += line + '\n'
|
||||||
if comment:
|
if comment:
|
||||||
comments += comment + '\n'
|
comments += comment + '\n'
|
||||||
|
|
@ -1869,7 +1869,9 @@ class Parser(object):
|
||||||
reaction, revReaction = self.readKineticsEntry(kinetics, surface)
|
reaction, revReaction = self.readKineticsEntry(kinetics, surface)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.line_number = line_number
|
self.line_number = line_number
|
||||||
logging.info('Error reading reaction entry starting on line {0}:'.format(line_number))
|
logging.info('Error reading reaction starting on '
|
||||||
|
'line {0}:\n"""\n{1}\n"""'.format(
|
||||||
|
line_number, kinetics.rstrip()))
|
||||||
raise
|
raise
|
||||||
reaction.line_number = line_number
|
reaction.line_number = line_number
|
||||||
reaction.comment = comment
|
reaction.comment = comment
|
||||||
|
|
@ -2198,9 +2200,9 @@ duplicate transport data) to be ignored.
|
||||||
try:
|
try:
|
||||||
# Read input mechanism files
|
# Read input mechanism files
|
||||||
parser.loadChemkinFile(inputFile)
|
parser.loadChemkinFile(inputFile)
|
||||||
except Exception:
|
except Exception as err:
|
||||||
logging.warning("\nERROR: Unable to parse '{0}' near line {1}:\n".format(
|
logging.warning("\nERROR: Unable to parse '{0}' near line {1}:\n{2}\n".format(
|
||||||
inputFile, parser.line_number))
|
inputFile, parser.line_number, err))
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
phaseName = None
|
phaseName = None
|
||||||
|
|
@ -2211,9 +2213,9 @@ duplicate transport data) to be ignored.
|
||||||
try:
|
try:
|
||||||
# Read input mechanism files
|
# Read input mechanism files
|
||||||
parser.loadChemkinFile(surfaceFile, surface=True)
|
parser.loadChemkinFile(surfaceFile, surface=True)
|
||||||
except Exception:
|
except Exception as err:
|
||||||
logging.warning("\nERROR: Unable to parse '{0}' near line {1}:\n".format(
|
logging.warning("\nERROR: Unable to parse '{0}' near line {1}:\n{2}\n".format(
|
||||||
surfaceFile, parser.line_number))
|
inputFile, parser.line_number, err))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if thermoFile:
|
if thermoFile:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue