errors.go (532B)
1 package retry 2 3 import "fmt" 4 5 // MaxAttemptsError provides the error when the maximum number of attempts have 6 // been exceeded. 7 type MaxAttemptsError struct { 8 Attempt int 9 Err error 10 } 11 12 func (e *MaxAttemptsError) Error() string { 13 return fmt.Sprintf("exceeded maximum number of attempts, %d, %v", e.Attempt, e.Err) 14 } 15 16 // Unwrap returns the nested error causing the max attempts error. Provides the 17 // implementation for errors.Is and errors.As to unwrap nested errors. 18 func (e *MaxAttemptsError) Unwrap() error { 19 return e.Err 20 }