Stop retry and trigger incident based on exception thrown

Hello,

We have a service task which is set with async before and a retry option. The delegate code (Java) for the service calls an external API and if a 4xx status code is returned, we would like to stop it from keep retrying (set the counter to zero?), end the entire flow and immediately create an incident.
Is there a way to do that?

You can throw a BpmnError and have a boundary error event.

There is also a Jira ticket for exactly what you want (don’t remember the number), but it hasn’t been implemented yet.

But a BpmnError will not create an incident, right?

Ah, now I remember. There is a process engine setting that does this (what to do in the case of an uncaught BpmnError). You should NOT have the boundary event, then an incident will be created.

The statement about the ticket still holds.