Hello, my friend!
Let’s summarize the step-by-step process:
1 - In your service task, create a “Connector output” as a String or expression to capture the status code with the value ${statusCode};
2 - In the same service task, configure an “execution listener - End” and set it as a script task.
3 - In the script of the execution listener, you will perform the desired treatment by either throwing a new org.camunda.bpm.engine.delegate.BpmnError(“yourBoundaryErrorEventName”) to propagate your instance to your error handling flow, or by throwing a new java.lang.Exception(response) to generate an incident in Camunda for manual treatment.
Sure, here’s a more detailed explanation: (I’m sorry, but as I don’t know your current level of knowledge, I took the liberty to provide a slightly more detailed explanation below in case you need it.)
I’ll give you a quick example of what can be done to handle this issue in your service task.
You will capture the response from your Service task, which could generate an error, and access its statusCode.
Then, you will configure an “Execution listener - End” to check if the statusCode is != 200 when your task is completed, and then handle it as desired.
To throw your instance into your error handling flow in Camunda, you should use “Throw new BpmnError,” as shown in the treatment below:
Alternatively, you can do it differently from my example by directly creating a response in Connector Output, only with statusCode using ${statusCode}
and doing the same treatment later in the execution listener, as shown below:
I hope this helps.
William Robert Alves