Skip to content

Commit 644a290

Browse files
author
Sahib Yar
committed
Moved closeResp(resp) inside function and closed body before retry and removed redundant code
1 parent 88a0be7 commit 644a290

File tree

7 files changed

+86
-139
lines changed

7 files changed

+86
-139
lines changed

alpaca/entities.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package alpaca
22

33
import (
44
json "encoding/json"
5-
"errors"
65
"fmt"
76
"io"
87
"net/http"
@@ -363,10 +362,7 @@ type APIError struct {
363362
}
364363

365364
func APIErrorFromResponse(resp *http.Response) error {
366-
if resp == nil {
367-
return errors.New("response is response")
368-
}
369-
defer resp.Body.Close()
365+
defer CloseResp(resp)
370366

371367
body, err := io.ReadAll(resp.Body)
372368
if err != nil {

0 commit comments

Comments
 (0)