When catching non-jinja errors from Jinja, raise a good error message, and make a best effort at tracking down the line number and error line if possible.
This commit is contained in:
parent
ab9614c6b4
commit
0e3ba4664f
|
@ -2,6 +2,7 @@
|
|||
import json
|
||||
import os
|
||||
import uuid
|
||||
from sys import exc_info
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
from typing import Optional
|
||||
|
@ -562,6 +563,20 @@ def _render_jinja_template(unprocessed_template: str, spiff_task: SpiffTask) ->
|
|||
"Jinja2 template errors can happen when trying to displaying task data"
|
||||
)
|
||||
raise wfe from template_error
|
||||
except Exception as error:
|
||||
type, value, tb = exc_info()
|
||||
wfe = WorkflowTaskException(
|
||||
str(error), task=spiff_task, exception=error
|
||||
)
|
||||
while tb:
|
||||
if tb.tb_frame.f_code.co_filename == '<template>':
|
||||
wfe.line_number = tb.tb_lineno
|
||||
wfe.error_line = unprocessed_template.split("\n")[tb.tb_lineno - 1]
|
||||
tb = tb.tb_next
|
||||
wfe.add_note(
|
||||
"Jinja2 template errors can happen when trying to displaying task data"
|
||||
)
|
||||
raise wfe from error
|
||||
|
||||
|
||||
def _get_spiff_task_from_process_instance(
|
||||
|
|
Loading…
Reference in New Issue