Skip to content

Commit 6080268

Browse files
committed
fix: add missing pointer check
Signed-off-by: rare-magma <[email protected]>
1 parent c1d5f5c commit 6080268

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ func shouldRetry(err error, resp *http.Response) bool {
3737
if err != nil {
3838
return true
3939
}
40+
if resp == nil {
41+
return true
42+
}
4043
switch resp.StatusCode {
4144
case http.StatusInternalServerError, http.StatusBadGateway, http.StatusServiceUnavailable, http.StatusGatewayTimeout:
4245
return true
@@ -63,7 +66,9 @@ func (t *retryableTransport) RoundTrip(req *http.Request) (*http.Response, error
6366
if req.Body != nil {
6467
req.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
6568
}
66-
log.Printf("Previous request failed with %s", resp.Status)
69+
if resp != nil {
70+
log.Printf("Previous request failed with %s", resp.Status)
71+
}
6772
log.Printf("Retry %d of request to: %s", retries+1, req.URL)
6873
resp, err = t.transport.RoundTrip(req)
6974
retries++

0 commit comments

Comments
 (0)