diff --git a/client.go b/client.go index 85c23f85..129982fa 100644 --- a/client.go +++ b/client.go @@ -626,8 +626,9 @@ func (c *Client) doWithEndpoint( } resp, respErr = c.doSingleRequest(req, authRequired, headers) - shouldRetry, delay := c.shouldRetry(resp, respErr, attempt) + // Handle retry if applicable + shouldRetry, delay := c.shouldRetry(resp, respErr, attempt) if !shouldRetry { break } @@ -636,8 +637,8 @@ func (c *Client) doWithEndpoint( case <-time.After(delay): continue case <-ctx.Done(): - respErr = fmt.Errorf("context completed during retry: %w", ctx.Err()) - return nil, respErr + err = fmt.Errorf("context completed during retry: %w", ctx.Err()) + return nil, err } }