Skip to content

Commit

Permalink
Print error to info log before backing off (#641)
Browse files Browse the repository at this point in the history
* Print error to info log before backing off

* Change LogInfo to LogError

Co-authored-by: Joel Hendrix <jhendrix@microsoft.com>
  • Loading branch information
Nirusu and jhendrixMSFT authored Aug 23, 2021
1 parent 34360dd commit 3ddafdd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions autorest/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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()
}
Expand Down

0 comments on commit 3ddafdd

Please sign in to comment.