Skip to content

Commit

Permalink
show more retry error message (#2290)
Browse files Browse the repository at this point in the history
  • Loading branch information
nexustar authored Oct 17, 2023
1 parent 8fd533d commit 9e47d78
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/utils/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ func Retry(doFunc func() error, opts ...RetryOption) error {

// call the function
var attemptCount int64
var err error
for attemptCount = 0; attemptCount < cfg.Attempts; attemptCount++ {
if err := doFunc(); err == nil {
if err = doFunc(); err == nil {
return nil
}

Expand All @@ -91,7 +92,7 @@ func Retry(doFunc func() error, opts ...RetryOption) error {
}
}

return fmt.Errorf("operation exceeds the max retry attempts of %d", cfg.Attempts)
return fmt.Errorf("operation exceeds the max retry attempts of %d. error of last attempt: %s", cfg.Attempts, err)
}

// IsTimeoutOrMaxRetry return true if it's timeout or reach max retry.
Expand Down

0 comments on commit 9e47d78

Please sign in to comment.