added more details in jinja

errors reporting
This commit is contained in:
2026-01-16 20:07:51 +01:00
parent df2a3a1681
commit 6ee74aa2af

View File

@@ -28,8 +28,19 @@ def template_to_test(filename: str, params: list):
try:
params["include_directory"] = os.path.dirname(os.path.abspath(filename))
tmpf.write(j2_template.render(params))
except (UndefinedError, TypeError):
raise ETUMSyntaxError(f"Template loading of file '{filename}' with following parameters '{str(params)}'")
except TemplateSyntaxError as e:
raise ECPTSyntaxError(f"""Template loading of file '{filename}' with following parameters '{str(params)}'
Syntax error in template: {e.message}""")
except UndefinedError as e:
raise ECPTSyntaxError(f"""Template loading of file '{filename}' with following parameters '{str(params)}'
Undefined variable error: {e.message}""")
except TemplateError as e:
raise ECPTSyntaxError(f"""Template loading of file '{filename}' with following parameters '{str(params)}'
Template rendering error: {e.message}""")
except Exception as e:
# Catch any other unexpected errors
raise ECPTSyntaxError(f"""Template loading of file '{filename}' with following parameters '{str(params)}'
Unexpected error: {str(e)}""")
# return to begining of the temp file
tmpf.seek(0, os.SEEK_SET)