@@ -82,38 +82,43 @@ public boolean execute(
82
82
taskOutput .put ("result" , evalResult );
83
83
task .setStatus (TaskModel .Status .COMPLETED );
84
84
} catch (Exception e ) {
85
+ String errorMessage = e .getCause () != null ? e .getCause ().getMessage () : e .getMessage ();
85
86
LOGGER .error (
86
87
"Failed to execute Inline Task: {} in workflow: {}" ,
87
88
task .getTaskId (),
88
89
workflow .getWorkflowId (),
89
90
e );
90
- task .setStatus (TaskModel .Status .FAILED );
91
- task .setReasonForIncompletion (e .getMessage ());
92
- taskOutput .put (
93
- "error" , e .getCause () != null ? e .getCause ().getMessage () : e .getMessage ());
91
+ // TerminateWorkflowException is thrown when the script evaluation fails
92
+ // Retry will result in the same error, so FAILED_WITH_TERMINAL_ERROR status is used.
93
+ task .setStatus (
94
+ e instanceof TerminateWorkflowException
95
+ ? TaskModel .Status .FAILED_WITH_TERMINAL_ERROR
96
+ : TaskModel .Status .FAILED );
97
+ task .setReasonForIncompletion (errorMessage );
98
+ taskOutput .put ("error" , errorMessage );
94
99
}
95
100
96
101
return true ;
97
102
}
98
103
99
104
private void checkEvaluatorType (String evaluatorType ) {
100
105
if (StringUtils .isBlank (evaluatorType )) {
101
- LOGGER .error ("Empty {} in Inline task. " , QUERY_EVALUATOR_TYPE );
106
+ LOGGER .error ("Empty {} in INLINE task. " , QUERY_EVALUATOR_TYPE );
102
107
throw new TerminateWorkflowException (
103
108
"Empty '"
104
109
+ QUERY_EVALUATOR_TYPE
105
- + "' in Inline task's input parameters. A non-empty String value must be provided." );
110
+ + "' in INLINE task's input parameters. A non-empty String value must be provided." );
106
111
}
107
112
if (evaluators .get (evaluatorType ) == null ) {
108
- LOGGER .error ("Evaluator {} for Inline task not registered" , evaluatorType );
113
+ LOGGER .error ("Evaluator {} for INLINE task not registered" , evaluatorType );
109
114
throw new TerminateWorkflowException (
110
- "Unknown evaluator '" + evaluatorType + "' in Inline task." );
115
+ "Unknown evaluator '" + evaluatorType + "' in INLINE task." );
111
116
}
112
117
}
113
118
114
119
private void checkExpression (String expression ) {
115
120
if (StringUtils .isBlank (expression )) {
116
- LOGGER .error ("Empty {} in Inline task. " , QUERY_EXPRESSION_PARAMETER );
121
+ LOGGER .error ("Empty {} in INLINE task. " , QUERY_EXPRESSION_PARAMETER );
117
122
throw new TerminateWorkflowException (
118
123
"Empty '"
119
124
+ QUERY_EXPRESSION_PARAMETER
0 commit comments