From 3ddafdd73fe99af09e2226b8b3e9472ca456e355 Mon Sep 17 00:00:00 2001 From: Nils Hanke Date: Mon, 23 Aug 2021 22:59:06 +0200 Subject: [PATCH] Print error to info log before backing off (#641) * Print error to info log before backing off * Change LogInfo to LogError Co-authored-by: Joel Hendrix --- autorest/sender.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autorest/sender.go b/autorest/sender.go index 6818bd185..7a495f732 100644 --- a/autorest/sender.go +++ b/autorest/sender.go @@ -272,6 +272,7 @@ func DoRetryForAttempts(attempts int, backoff time.Duration) SendDecorator { if err == nil { return resp, err } + logger.Instance.Writef(logger.LogError, "DoRetryForAttempts: received error for attempt %d: %v\n", attempt+1, err) if !DelayForBackoff(backoff, attempt, r.Context().Done()) { return nil, r.Context().Err() } @@ -326,6 +327,9 @@ func doRetryForStatusCodesImpl(s Sender, r *http.Request, count429 bool, attempt if err == nil && !ResponseHasStatusCode(resp, codes...) || IsTokenRefreshError(err) { return resp, err } + if err != nil { + logger.Instance.Writef(logger.LogError, "DoRetryForStatusCodes: received error for attempt %d: %v\n", attempt+1, err) + } delayed := DelayWithRetryAfter(resp, r.Context().Done()) // if this was a 429 set the delay cap as specified. // applicable only in the absence of a retry-after header. @@ -392,6 +396,7 @@ func DoRetryForDuration(d time.Duration, backoff time.Duration) SendDecorator { if err == nil { return resp, err } + logger.Instance.Writef(logger.LogError, "DoRetryForDuration: received error for attempt %d: %v\n", attempt+1, err) if !DelayForBackoff(backoff, attempt, r.Context().Done()) { return nil, r.Context().Err() }