From 2e56ecce6e3aa9761a19fa384f5412f6085c1903 Mon Sep 17 00:00:00 2001 From: nexustar Date: Tue, 17 Oct 2023 17:25:00 +0800 Subject: [PATCH] show more retry error message --- pkg/utils/retry.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/utils/retry.go b/pkg/utils/retry.go index 0a6c65a409..a958b8c0b2 100644 --- a/pkg/utils/retry.go +++ b/pkg/utils/retry.go @@ -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 } @@ -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.