diff options
Diffstat (limited to 'src/tools/ivigenerator/generator/global_functions.py')
-rw-r--r-- | src/tools/ivigenerator/generator/global_functions.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/tools/ivigenerator/generator/global_functions.py b/src/tools/ivigenerator/generator/global_functions.py index 6794fc5..1ef8b60 100644 --- a/src/tools/ivigenerator/generator/global_functions.py +++ b/src/tools/ivigenerator/generator/global_functions.py @@ -39,6 +39,12 @@ # # SPDX-License-Identifier: LGPL-3.0 +import inspect +import click + +from jinja2 import TemplateAssertionError +from jinja2 import contextfunction + def jinjaTrace(): """ Collects all jinja template files and the line numbers from the current calltrace @@ -53,7 +59,8 @@ def jinjaTrace(): return infos -def jinja_error(msg): +@contextfunction +def jinja_error(context, msg): """ Throws an error for the current jinja template and the templates this is included from This can be used inside a filter to indicate problems with the passed arguments or direclty inside @@ -65,7 +72,7 @@ def jinja_error(msg): if len(infos) > 1: for info in infos[1:]: message = message + "\n{0}:{1}: instantiated from here".format(info[0], info[1]) - message = message + "\n{0}: instantiated from here".format(currentQFaceSrcFile) + message = message + "\n{0}: instantiated from here".format(context["srcFile"]) raise TemplateAssertionError(message, infos[0][1], "", infos[0][0]) raise TemplateAssertionError(msg, -1, "", "unknown") |