Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit 3ddafdd

Browse files
NirusujhendrixMSFT
andauthored
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 <[email protected]>
1 parent 34360dd commit 3ddafdd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

autorest/sender.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ func DoRetryForAttempts(attempts int, backoff time.Duration) SendDecorator {
272272
if err == nil {
273273
return resp, err
274274
}
275+
logger.Instance.Writef(logger.LogError, "DoRetryForAttempts: received error for attempt %d: %v\n", attempt+1, err)
275276
if !DelayForBackoff(backoff, attempt, r.Context().Done()) {
276277
return nil, r.Context().Err()
277278
}
@@ -326,6 +327,9 @@ func doRetryForStatusCodesImpl(s Sender, r *http.Request, count429 bool, attempt
326327
if err == nil && !ResponseHasStatusCode(resp, codes...) || IsTokenRefreshError(err) {
327328
return resp, err
328329
}
330+
if err != nil {
331+
logger.Instance.Writef(logger.LogError, "DoRetryForStatusCodes: received error for attempt %d: %v\n", attempt+1, err)
332+
}
329333
delayed := DelayWithRetryAfter(resp, r.Context().Done())
330334
// if this was a 429 set the delay cap as specified.
331335
// applicable only in the absence of a retry-after header.
@@ -392,6 +396,7 @@ func DoRetryForDuration(d time.Duration, backoff time.Duration) SendDecorator {
392396
if err == nil {
393397
return resp, err
394398
}
399+
logger.Instance.Writef(logger.LogError, "DoRetryForDuration: received error for attempt %d: %v\n", attempt+1, err)
395400
if !DelayForBackoff(backoff, attempt, r.Context().Done()) {
396401
return nil, r.Context().Err()
397402
}

0 commit comments

Comments
 (0)