Catch-all transition declined exception

瀏覽次數:37 次
跳到第一則未讀訊息

Mike

未讀,
2018年11月15日 晚上7:36:062018/11/15
收件者:squirrel state machine
I realize this group is a little old so I'm hoping someone is still monitoring it...

I can't find a way to have the state machine throw an exception when a transition is declined due to the fact that it was never declared.  If I have 10 states and 9 events to move through them, I don't want to have to declare a transition for every possible invalid transition. It seems that when the default afterTransitionDeclined() method is called, it would be nice if I could throw an exception there and have it bubble up to the method that called the original fire() method so that it could respond with some type of failure report (as the case with a web service). As it is, the only way I can see to catch a failed transition is to check the state of the state machine to see if its in error, OR, check to see if the state didn't change. Neither seem as intuitive as catching a TransitionException and handling it that way.

I might have missed something in the documentation, but is there a way to do this without having to declare all of the invalid transition possibilities?

When I look at the StateMachineExceptionTest, the testExceptionFail looks like what I'd want, but it relies on the transitFromAToCOnToC throwing the exception. I'm hoping there's way to just do that for any undeclared/invalid transition.

Thanks for any help,

Mike
回覆所有人
回覆作者
轉寄
0 則新訊息