Skip to content

Commit

Permalink
chore: improve exception msg
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Nov 18, 2023
1 parent 730d703 commit ec35948
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/jinjarope/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import weakref

import jinja2

from jinja2.exceptions import TemplateSyntaxError
import jinja2.nodes

import jinjarope
Expand Down Expand Up @@ -299,7 +301,11 @@ def render_string(
"""
variables = (variables or {}) | kwargs
cls = self.template_class
template = cls.from_code(self, self.compile(string), self.globals, None)
try:
template = cls.from_code(self, self.compile(string), self.globals, None)
except TemplateSyntaxError as e:
msg = f"Error when evaluating \n{string}\n (extra globals: {variables})"
raise SyntaxError(msg) from e
return template.render(**variables)

def render_file(
Expand Down

0 comments on commit ec35948

Please sign in to comment.