1
0
Fork 0
mirror of https://github.com/Luzifer/go_helpers.git synced 2024-12-26 14:01:20 +00:00
go_helpers/backoff/error.go

26 lines
641 B
Go
Raw Normal View History

package backoff
import "fmt"
type (
// ErrCannotRetry wraps the original error and signals the backoff
// should be stopped now as a retry i.e. would be harmful or would
// make no sense
ErrCannotRetry struct{ inner error }
)
// NewErrCannotRetry wraps the given error into an ErrCannotRetry and
// should be used to break from a Retry() function when the retry
// should stop immediately
func NewErrCannotRetry(err error) error {
return ErrCannotRetry{err}
}
func (e ErrCannotRetry) Error() string {
return fmt.Sprintf("retry cancelled by error: %s", e.inner.Error())
}
func (e ErrCannotRetry) Unwrap() error {
return e.inner
}