From 466450f0c47bdc614e66326d90e5fc6fb56ae732 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Mon, 2 May 2022 14:34:35 +0200 Subject: Refactor: Wrap most errors in a custom type --- internal/fsm.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'internal/fsm.go') diff --git a/internal/fsm.go b/internal/fsm.go index 1bcc479..0b9ad1e 100644 --- a/internal/fsm.go +++ b/internal/fsm.go @@ -206,3 +206,21 @@ func (fsm *FSM) generateMermaidGraph() string { func (fsm *FSM) GenerateGraph() string { return fsm.generateMermaidGraph() } + +type FSMWrongStateTransitionError struct { + Got FSMStateID + Want FSMStateID +} + +func (e *FSMWrongStateTransitionError) Error() string { + return fmt.Sprintf("wrong FSM state, got: %s, want a state with a transition to: %s", e.Got.String(), e.Want.String()) +} + +type FSMWrongStateError struct { + Got FSMStateID + Want FSMStateID +} + +func (e *FSMWrongStateError) Error() string { + return fmt.Sprintf("wrong FSM state, got: %s, want: %s", e.Got.String(), e.Want.String()) +} -- cgit v1.2.3