You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 and action 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.
In the case of guard, the guard just returns false when an exception occurs.
In the case of action, no transition occurs when an exception occurs.
Is there an option to throw an internal exception to the outside?
The text was updated successfully, but these errors were encountered:
KimDoubleB
changed the title
Is there any way to throw an exception that occurred inside the State Machine to the outside?
Is there way to throw an Exception that occurred inside the Statemachine to the outside?
Jun 16, 2022
State Machines runs with some principle called 'Run to Completion' as defined in this links 12, 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?
The text was updated successfully, but these errors were encountered: