Exception in @OnTransition method does not prevent state transition
An unhandled exception in a transition handler does not prevent the transition or provide any way of detecting and reacting to the problem.
@OnTransition
public void onClosed() {
throw new RuntimeException();
}
The transition continues successfully, the exception is logged and swallowed and no listeners are invoked.
In situations like this an exception is exactly what I want (eg when there's a bug in my handler); why not let the error propagate to the calling code that can handle it it instead of swallowing it?
In general I don't understand this project's error handling strategy; why is there no way to fail fast? I am concerned about bugs being silently swallowed in these and other situations, eg. if I don't define an error handler for an action.
These callbacks to annotated methods are currently implemented via listener interfaces and errors in those cannot halt anything in a statemachine. Only interceptors can halt transitions and it might be further development to implement better features around this topic.
Thanks for the response @jvalkeal. Is there no way to allow exceptions to propagate to the sender of the event, and if so why?
Now that github discussion are available, I'm gonna post a topic(to have this in one place) there to kickstart a discussion about this as error handling is relatively complex topic in a statemachine context. I want to share some info why it is like this.