Skip to content

Commit 231f664

Browse files
committed
Extra debugging message for loading a KineticsDB
1 parent 3c99f93 commit 231f664

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

rmgpy/data/kinetics/library.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,16 @@ def load(self, path, local_context=None, global_context=None):
464464
local_context[key] = value
465465

466466
# Process the file
467-
f = open(path, 'r')
467+
with open(path, 'r') as f:
468+
content = f.read()
468469
try:
469-
exec(f.read(), global_context, local_context)
470-
except Exception:
471-
logging.error('Error while reading database {0!r}.'.format(path))
470+
exec(content, global_context, local_context)
471+
except Exception as e:
472+
logging.exception(f'Error while reading database file {path}.')
473+
line_number = e.__traceback__.tb_next.tb_lineno
474+
logging.error(f'Error occurred at or near line {line_number} of {path}.')
475+
lines = content.splitlines()
476+
logging.error(f'Line: {lines[line_number - 1]}')
472477
raise
473478
f.close()
474479

0 commit comments

Comments
 (0)