The generated root state machine of Designer service comes with an integrated error handling.
All errors that occur on process execution are caught.
Executable processes work with the concept of transactions. Transactions are equivalent to units of work, that are committed at the end of the session. In case an error occurs during a transaction, the following happens:
The error is caught. When an exception occurs and is not explicitly caught in the execution diagram by the modeler, the current implementation (and persistent state transaction) skips to its end. All subsequent code is skipped. Then, the error is caught by the persistent state engine.
The error handler is invoked. The error handler sends an error signal (handleErrorSignal) to the root state machine.
The process switches into the error state at transaction end. The persistent state engine commits the transaction - and also the error signal. The process switches to the next process step but then goes to the error state.
The process instance is displayed as erroneous. You can now
Rectify the error and send a retry signal You can now look into the error and apply fixes if necessary. The last process step the process has reached is marked by a history state, so it is possible to trigger a retry from this very step. You can either trigger a manual retry, or the process could have auto retry enabled and automatically performs retries in given intervals.
Abort the process instance
Alternatively, you can abort the process instance by sending an abort signal. In this case, the process instance will be terminated as aborted (not done).
Behavior of the State Machine
Depending on the BPMN Element you have added your execution implementation to, the process state machine shows a different behavior.
Error In
BPMN Element
Behavior
On Event
Start Event
Timer Start Event
Message Start Event
Plain Event
Timer Event
Message Event
End Event
The process state engine goes to next process step.
The process instance is in error state.
All subsequent code after the exception is skipped.
On Exit
Service Task
Receive Task
User Task
Get Data
User Task
Implementations in the Get Data execution do not have any effect on the persistent state engine (no error state).
On error, the form loads nevertheless but the form will not be initialized in any way.
Decision
Exclusive Gateway
The process instance does not go to error state.
The process is rolled back to the previous state.
A log message is logged to the service log: Allowing guard functions to throw exceptions is considered a very bad practise, so, even though error handler will be executed, transaction will be rolled back. You probably should rethink your design.