Merge branch 'master' of github.com:zzzeek/mako
diff --git a/doc/build/changelog.rst b/doc/build/changelog.rst
index 2a0e5f3..b89ba66 100644
--- a/doc/build/changelog.rst
+++ b/doc/build/changelog.rst
@@ -10,6 +10,14 @@
:released:
.. change::
+ :tags: feature
+ :pullreq: bitbucket:4
+
+ The mako-render script will now catch exceptions and run them
+ into the text error handler, and exit with a non-zero exit code.
+ Pull request courtesy Derek Harland.
+
+ .. change::
:tags: feature, py3k
:pullreq: github:7
diff --git a/scripts/mako-render b/scripts/mako-render
index 122589f..2b951ab 100755
--- a/scripts/mako-render
+++ b/scripts/mako-render
@@ -48,7 +48,13 @@
kw = dict([varsplit(var) for var in opts.var])
data = fo.read()
- print(render(data, kw, lookup_dirs=lookup_dirs))
+
+ try:
+ print(render(data, kw, lookup_dirs=lookup_dirs))
+ except:
+ from mako import exceptions
+ print(exceptions.text_error_template().render(), file=sys.stderr)
+ sys.exit(1)
if __name__ == "__main__":
main()