Raise on init, parse, render, or write fails

If jinja template initialization, parsing, rendering, or writing fails,
we used to sometimes log an error message, then sometimes continue
(ignoring the failure), sometimes reraise the exception, and sometimes
fail without raising the exception.  With this change, we always raise
the exception so we print the traceback and fail the build right away.

Change-Id: I04a36c4c8c69dbd08e9ea677983dbe00fa3a67a3
This commit is contained in:
Eric Fried 2017-10-22 13:49:41 -05:00
parent a23ecbf84a
commit 4f236a3f70
1 changed files with 2 additions and 1 deletions

View File

@ -434,6 +434,7 @@ def render_template(environment, project_data, regular_repos, infra_repos,
fh.write(output.encode('utf8'))
except (IOError, OSError, UnicodeEncodeError) as e:
logger.error("writing %s failed: %s" % (target_file, e))
raise
def main():
@ -457,7 +458,7 @@ def main():
environment = jinja2.Environment(loader=loader)
except Exception as e:
logger.error("initialising template environment failed: %s" % e)
return 1
raise
if args.skip_render:
return 0