Raise if parsing, rendering, or writing fails

If jinja template parsing, rendering, or writing fails, we used to log
an error message and continue.  With this change, we'll raise the
original exception so we print the traceback and fail the build right
away.

Change-Id: I9e92d3aed844d965a425c43c79a8844e5c4bd006
This commit is contained in:
Eric Fried 2017-10-22 13:27:13 -05:00
parent 39b270b51d
commit 9380aeee17
1 changed files with 4 additions and 4 deletions

View File

@ -65,7 +65,7 @@ def main():
environment = jinja2.Environment(loader=loader)
except Exception as e:
logger.error("initialising template environment failed: %s" % e)
return 1
raise
for templateFile in environment.list_templates():
if not templateFile.endswith('.html'):
@ -78,7 +78,7 @@ def main():
except Exception as e:
logger.error("parsing template %s failed: %s" %
(templateFile, e))
continue
raise
try:
output = lxml.html.tostring(
@ -87,7 +87,7 @@ def main():
except Exception as e:
logger.error("rendering template %s failed: %s" %
(templateFile, e))
continue
raise
try:
target_directory = os.path.join(args.output_directory,
@ -102,7 +102,7 @@ def main():
fh.write(output.encode('utf8'))
except (IOError, OSError, UnicodeEncodeError) as e:
logger.error("writing %s failed: %s" % (target_file, e))
continue
raise
return 0