Replika.Error.InvalidTransitionError exception (Replika v0.1.0)
View SourceRaised when attempting an event transition that isn't defined for the current state.
This error provides detailed information about:
- The current state of the FSM
- The event that was attempted
- Any arguments passed to the event
Examples
try do
Unit.AccessState.new()
|> Unit.AccessState.pickup_card()
|> Unit.AccessState.pickup_card() # Can't pickup card when already have one
rescue
e in InvalidTransitionError ->
# e.state == :has_id_card
# e.event == :pickup_card
# e.args == []
IO.puts(e.message)
end
Troubleshooting
This error usually indicates one of these issues:
- Calling an event in the wrong state (state machine logic error)
- Missing a state definition for a necessary transition
- Missing an event definition for a valid use case
Review your state machine definition and ensure all valid state transitions are properly defined.