ExGram.FSM.TransitionError exception (ExGram FSM v0.1.0)

Copy Markdown View Source

Exception raised when an invalid FSM transition is attempted and the on_invalid_transition policy is :raise (the default).

Fields

  • message - human-readable error message
  • from - the source state atom
  • to - the attempted target state atom

Example

# When :raise policy is active:
transition(context, :confirm)
# => raises %ExGram.FSM.TransitionError{from: :idle, to: :confirm, ...}

Handling in the bot

def handle_error(%ExGram.Error{error: %ExGram.FSM.TransitionError{from: from, to: to}}) do
  Logger.error("Invalid FSM transition: #{from} -> #{to}")
end