StateMachine icon indicating copy to clipboard operation
StateMachine copied to clipboard

Throw exception on the wrong event

Open chirillkirkin opened this issue 6 years ago • 2 comments

What if state machine will throw an exception when we try to do transition to some state by undeclared event (sorry for my english). For example: declaring state machine behaviour

initialState(State.SomeState)
state<State.SomeState> {
            on<Event.SomeEvent> {
                transitionTo(State.AnotherState, SideEffect.SomeSideEffect)
            }
}

then we trying to do undeclared transition (from state "SomeState") stateMachine.transition(Event.SomeOtherEvent) //<- there is should be thrown an exception

chirillkirkin avatar Jan 31 '19 18:01 chirillkirkin

@Keyrillanskiy Currently, when that happens (undeclared event), it returns a Transition.Invalid object. Does that work for you?

zhxnlai avatar Jan 31 '19 20:01 zhxnlai

@zhxnlai Just in my opinion, when FSM doing something wrong, there is should be an exception ¯_(ツ)_/¯

chirillkirkin avatar Feb 01 '19 19:02 chirillkirkin