summaryrefslogtreecommitdiff
path: root/bilibili/request.go
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-09-07 10:18:55 +0800
committerKeuin <[email protected]>2022-09-07 10:18:55 +0800
commitc72e692be33d5ab2884db6e2f1cf027f150a108a (patch)
tree170ea1989d215d0fede3f762f344bfb55e4c3fb3 /bilibili/request.go
parent2033d66ce1fcbd6b5be00f35f9f2e1c07b5a8ba7 (diff)
Bugfix: callGet[T] will panic if the request is unsuccessful
Diffstat (limited to 'bilibili/request.go')
-rw-r--r--bilibili/request.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/bilibili/request.go b/bilibili/request.go
index cb989a7..c31cf75 100644
--- a/bilibili/request.go
+++ b/bilibili/request.go
@@ -38,11 +38,11 @@ func callGet[T BaseResponse[V], V any](b Bilibili, url string) (resp T, err erro
}
r, err := b.http.Do(req)
- defer func() { _ = r.Body.Close() }()
if err != nil {
logger.Printf("ERROR: HTTP Request failed on API %v: %v", url, err)
return
}
+ defer func() { _ = r.Body.Close() }()
err = validateHttpStatus(r)
if err != nil {