Skip to content

Commit

Permalink
show more retry error message
Browse files Browse the repository at this point in the history
  • Loading branch information
nexustar committed Oct 17, 2023
1 parent 9d1ba4b commit 2e56ecc
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 2e56ecc

Please sign in to comment.