From 59c10c17787696698f5a9622619e3a0d6eef280f Mon Sep 17 00:00:00 2001 From: jasquat Date: Tue, 13 Sep 2022 10:39:08 -0400 Subject: [PATCH] display the evaluation error when evaluating an expression instead of the NoneType error w/ burnettk --- .../routes/process_api_blueprint.py | 2 ++ .../services/process_instance_processor.py | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/spiffworkflow_backend/routes/process_api_blueprint.py b/src/spiffworkflow_backend/routes/process_api_blueprint.py index 39373cd4..dcda98b6 100644 --- a/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -330,6 +330,8 @@ def process_instance_run( if do_engine_steps: try: processor.do_engine_steps() + except ApiError as e: + raise e except Exception as e: ErrorHandlingService().handle_error(processor, e) task = processor.bpmn_process_instance.last_task diff --git a/src/spiffworkflow_backend/services/process_instance_processor.py b/src/spiffworkflow_backend/services/process_instance_processor.py index a69e7a81..9ebdec74 100644 --- a/src/spiffworkflow_backend/services/process_instance_processor.py +++ b/src/spiffworkflow_backend/services/process_instance_processor.py @@ -97,11 +97,18 @@ class CustomBpmnScriptEngine(PythonScriptEngine): # type: ignore try: return super()._evaluate(expression, context) except Exception as exception: - raise WorkflowTaskExecException( - task, - "Error evaluating expression " - "'%s', %s" % (expression, str(exception)), - ) from exception + if task is None: + raise ApiError( + "error_evaluating_expression", + "Error evaluating expression: " + "'%s', exception: %s" % (expression, str(exception)), + ) from exception + else: + raise WorkflowTaskExecException( + task, + "Error evaluating expression " + "'%s', %s" % (expression, str(exception)), + ) from exception def execute(self, task: SpiffTask, script: str) -> None: """Execute."""