2024-05-13 19:21:34 +03:00
|
|
|
package fsmwizard
|
2024-05-13 16:57:55 +03:00
|
|
|
|
|
|
|
import (
|
2024-05-13 19:08:46 +03:00
|
|
|
"gitea.neur0tx.site/Neur0toxine/vegapokerbot/pkg/fsm"
|
2024-05-13 16:57:55 +03:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ErrorState struct {
|
|
|
|
fsm.ErrorState[Wizard]
|
|
|
|
log *zap.SugaredLogger
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewErrorState(log *zap.SugaredLogger) *ErrorState {
|
|
|
|
return &ErrorState{log: log}
|
|
|
|
}
|
|
|
|
|
2024-05-14 14:44:41 +03:00
|
|
|
func (s *ErrorState) Handle(err error, cur fsm.StateID, next fsm.StateID, pl *Wizard, mc fsm.MachineControls[Wizard]) {
|
2024-05-13 16:57:55 +03:00
|
|
|
s.log.Errorf("critical wizard error: %s, current state: %s, next state: %s, payload: %#v",
|
|
|
|
err, cur, next, pl)
|
|
|
|
mc.Reset()
|
|
|
|
}
|