Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templater.py @ 17383:099c778ceb33
templater: abort when a template filter raises an exception (issue2987)
author | Neil Kodner <neilk@fb.com> |
---|---|
date | Fri, 17 Aug 2012 15:12:01 -0700 |
parents | 39c01f8e7b39 |
children | 0b241d7a8c62 |
line wrap: on
line diff
--- a/mercurial/templater.py Sat Aug 11 12:45:53 2012 -0500 +++ b/mercurial/templater.py Fri Aug 17 15:12:01 2012 -0700 @@ -146,7 +146,15 @@ def runfilter(context, mapping, data): func, data, filt = data - return filt(func(context, mapping, data)) + try: + return filt(func(context, mapping, data)) + except (ValueError, AttributeError, TypeError): + if isinstance(data, tuple): + dt = data[1] + else: + dt = data + raise util.Abort(_("template filter '%s' is not compatible with " + "keyword '%s'") % (filt.func_name, dt)) def buildmap(exp, context): func, data = compileexp(exp[1], context)