github.com/koko1123/flow-go-1@v0.29.6/module/dkg/errors.go (about) 1 package dkg 2 3 import ( 4 "errors" 5 "fmt" 6 ) 7 8 // InvalidStateTransitionError happens when an invalid DKG state transition is 9 // attempted. 10 type InvalidStateTransitionError struct { 11 From State 12 To State 13 } 14 15 // NewInvalidStateTransitionError creates a new InvalidStateTransitionError 16 // between the specified states. 17 func NewInvalidStateTransitionError(from State, to State) InvalidStateTransitionError { 18 return InvalidStateTransitionError{ 19 From: from, 20 To: to, 21 } 22 } 23 24 func (e InvalidStateTransitionError) Error() string { 25 return fmt.Sprintf("Invalid DKG state transition from %s to %s", e.From, e.To) 26 } 27 28 func IsInvalidStateTransitionError(err error) bool { 29 var errInvalidStateTransition InvalidStateTransitionError 30 return errors.As(err, &errInvalidStateTransition) 31 }