Skip to content

Commit

Permalink
Catch all Yaml reader exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
marble committed May 29, 2019
1 parent 7fb5513 commit bf8b538
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,21 @@ def lookup(D, *keys, **kwdargs):
settingsyml = None
settingsyml_file = milestones['settingsyml_file']
with codecs.open(settingsyml_file, 'r', 'utf-8') as f1:
reason = ''
try:
settingsyml = yaml.safe_load(f1)
except yaml.parser.ParserError:
settingsyml = None
reason = 'yaml.parser.ParserError'
except yaml.scanner.ScannerError:
settingsyml = None
reason = 'yaml.scanner.ScannerError'
except:
settingsyml = None
reason = 'unexpected exception'
if settingsyml is None:
loglist.append(('error: cannot parse `settingsyml_file`', settingsyml_file))
loglist.append(('error: cannot parse `settingsyml_file`', settingsyml_file,
'reason:', reason))
exitcode = 22

if exitcode == CONTINUE:
Expand Down

0 comments on commit bf8b538

Please sign in to comment.