Skip to content

Commit

Permalink
Merge branch 'main' into test_rms
Browse files Browse the repository at this point in the history
  • Loading branch information
hwpang authored May 20, 2024
2 parents 92ee4fd + d426379 commit a7fe72f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions rmgpy/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,17 @@ def load(self, path, local_context=None, global_context=None):
local_context[key] = value

# Process the file
f = open(path, 'r')
with open(path, 'r') as f:
content = f.read()
try:
exec(f.read(), global_context, local_context)
except Exception:
logging.error('Error while reading database {0!r}.'.format(path))
exec(content, global_context, local_context)
except Exception as e:
logging.exception(f'Error while reading database file {path}.')
line_number = e.__traceback__.tb_next.tb_lineno
logging.error(f'Error occurred at or near line {line_number} of {path}.')
lines = content.splitlines()
logging.error(f'Line: {lines[line_number - 1]}')
raise
f.close()

# Extract the database metadata
self.name = local_context['name']
Expand Down

0 comments on commit a7fe72f

Please sign in to comment.