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
I'm using Spring StateMachine 2.0.2 and can find hasStateMachineError() on StateMachine which is nice to check whether an error happened during transition. The problem is, there's no method to actually access what exception occurred. It would be nice if there would be something like getStateMachineError() or something to get access to the exception that was thrown.
The text was updated successfully, but these errors were encountered:
@vghero To gain access to the exception, you need to configure your state machine with a StateMachineListener. The docs recommend extending StateMachineListenerAdapter:
public class MyStateMachineListener extends StateMachineListenerAdapter<State, Event> {
@Override
public void stateMachineError(StateMachine<State, Event> stateMachine, Exception exception) {
// Access your exception here
}
}
Then you inject an instantiation of your listener into your state machine configuration:
Thanks, that could work. My workaround was, to simply pass a generic error action to the action configuration that simply propagates that exception to the state context's extended state. But your suggestion is cleaner and less boilerplate.
I'm using Spring StateMachine 2.0.2 and can find
hasStateMachineError()
onStateMachine
which is nice to check whether an error happened during transition. The problem is, there's no method to actually access what exception occurred. It would be nice if there would be something likegetStateMachineError()
or something to get access to the exception that was thrown.The text was updated successfully, but these errors were encountered: