summaryrefslogtreecommitdiff
path: root/internal/fsm.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-05-02 14:34:35 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-05-02 14:34:35 +0200
commit466450f0c47bdc614e66326d90e5fc6fb56ae732 (patch)
treea01518a58d50d2f8449d37dadecc40e35c9f1fe1 /internal/fsm.go
parenta2a8efdcaad3d9b1852b1367a7cd7e8c5860cecf (diff)
Refactor: Wrap most errors in a custom type
Diffstat (limited to 'internal/fsm.go')
-rw-r--r--internal/fsm.go18
1 files changed, 18 insertions, 0 deletions
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())
+}