Understanding custom incident creation behaviour

When you use the createIncident() method it creates the incident, but it is non-blocking and does not cause a rollback.
When you throw your exception, you are causing a rollback / engine to stop that process. Your failed job incident should have the “throwing from incident test task” text in its message

If you want to register new incidents, you need to create a new incident handler and register it during engine startup.

take a look at this repo for a deeper example;

In your case rather than running some JS, you just want to be registering your custom incident rather than the default failedJob type. I believe most of this is non-public APIs so usage wont be the most pretty.

3 Likes