aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimofey Titovets <nefelim4ag@gmail.com>2025-03-08 00:32:31 +0100
committerGitHub <noreply@github.com>2025-03-07 18:32:31 -0500
commitb50d7405429cbdbac7de8442f9ce31a032c3c584 (patch)
treeb33a6fa63795ae8ef19bbb6078fef6e027e75c3f
parent3e7efe5ef1468bf221c47bcd72624878f021fdae (diff)
downloadkutter-b50d7405429cbdbac7de8442f9ce31a032c3c584.tar.gz
kutter-b50d7405429cbdbac7de8442f9ce31a032c3c584.tar.xz
kutter-b50d7405429cbdbac7de8442f9ce31a032c3c584.zip
gcode_macro: Expand template syntax errors (#6839)
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
-rw-r--r--klippy/extras/gcode_macro.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/klippy/extras/gcode_macro.py b/klippy/extras/gcode_macro.py
index 78cdae0e..f244b344 100644
--- a/klippy/extras/gcode_macro.py
+++ b/klippy/extras/gcode_macro.py
@@ -49,6 +49,12 @@ class TemplateWrapper:
self.create_template_context = gcode_macro.create_template_context
try:
self.template = env.from_string(script)
+ except jinja2.exceptions.TemplateSyntaxError as e:
+ lines = script.splitlines()
+ msg = "Error loading template '%s'\nline %s: %s # %s" % (
+ name, e.lineno, lines[e.lineno-1], e.message)
+ logging.exception(msg)
+ raise self.gcode.error(msg)
except Exception as e:
msg = "Error loading template '%s': %s" % (
name, traceback.format_exception_only(type(e), e)[-1])