Skip to content

Commit

Permalink
Trap AttributeError and KeyError in config parsing and rethrow with b…
Browse files Browse the repository at this point in the history
…etter error message.
  • Loading branch information
baagaard-usgs committed Jun 13, 2019
1 parent 5a1873d commit 569e556
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pyre/inventory/cfg/CodecConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ def _decode(self, shelf):
basename = splitext(fn)[0]
macros = { 'td': td, 'basename': basename }
parser = Parser(root, macros=macros)
parser.read(shelf.name)
try:
parser.read(shelf.name)
except (AttributeError, KeyError) as err:
raise AttributeError("Error parsing '{fp.name}' line {fp.lineno}".format(fp=parser._sections.fp))
shelf['inventory'] = root
shelf._frozen = True
return
Expand Down

0 comments on commit 569e556

Please sign in to comment.