Closed KimDoubleB closed 2 years ago
State Machines runs with some principle called 'Run to Completion' as defined in this links 1 2, which in short means, when a state machine receives an Event it should start from a State and reach a State.
Now if an Action or Guard cause an exception and interrupts the Event processing and prevents State Machine reaches a State, this would be an undefined behaviour and unacceptable for State Machines.
For this reason, State Machines would not let exceptions escape outside of execution loop.
If there is chance an exception can occur in Guard/Action, it is developers responsibility to deal with it, by writing necessary code for it.
In Spring State Machine there is Event Listener which will trigger it when an Exception occurs, to notify the external client, but that will not stop the execution of the State Machine.
@mehmetsalgar Thank you for your kind explanation. I understood everything through your explanation. Also, looking at the links you attached, it seems that there are many concepts that I get to know. It's getting more interesting. I'll have to see if I can implement the logic I want using Event Listener. Thank you very much.
Hi. I recently got to know
spring-statemachine
, and I'm learning to use it for a company project.But there's a problem. There are cases where the logic of
guard
andaction
that I wrote generates an exception, and I want to process this exception outside of the state machine. But spring-statemachine handles all these exceptions internally.guard
, the guard just returns false when an exception occurs.action
, no transition occurs when an exception occurs.Is there an option to throw an internal exception to the outside?