improved exception system. now both name (load name) and filename are passed.
--HG--
branch : trunk
diff --git a/jinja2/ext.py b/jinja2/ext.py
index bd64cce..a489f97 100644
--- a/jinja2/ext.py
+++ b/jinja2/ext.py
@@ -149,9 +149,9 @@
name = parser.stream.expect('name')
if name.value in variables:
- raise TemplateAssertionError('translatable variable %r defined '
- 'twice.' % name.value, name.lineno,
- parser.filename)
+ parser.fail('translatable variable %r defined twice.' %
+ name.value, name.lineno,
+ exc=TemplateAssertionError)
# expressions
if parser.stream.current.type is 'assign':
@@ -202,8 +202,7 @@
if not have_plural:
plural_expr = None
elif plural_expr is None:
- raise TemplateAssertionError('pluralize without variables',
- lineno, parser.filename)
+ parser.fail('pluralize without variables', lineno)
if variables:
variables = nodes.Dict([nodes.Pair(nodes.Const(x, lineno=lineno), y)
@@ -236,15 +235,10 @@
elif parser.stream.current.test('name:pluralize'):
if allow_pluralize:
break
- raise TemplateSyntaxError('a translatable section can '
- 'have only one pluralize '
- 'section',
- parser.stream.current.lineno,
- parser.filename)
- raise TemplateSyntaxError('control structures in translatable'
- ' sections are not allowed.',
- parser.stream.current.lineno,
- parser.filename)
+ parser.fail('a translatable section can have only one '
+ 'pluralize section')
+ parser.fail('control structures in translatable sections are '
+ 'not allowed')
else:
assert False, 'internal parser error'