Skip to content

Commit

Permalink
check error before using response (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
airportyh authored Jun 25, 2024
1 parent ffd69e6 commit 91c21f5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/backends/python/search_pypi.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ func SearchPypi(query string) ([]api.PkgInfo, error) {
return nil, err
}
resp, err := api.HttpClient.Do(req)
if resp.StatusCode != 200 {
return nil, fmt.Errorf("Request to %s failed with %s", endpoint, resp.Status)
}
if err != nil {
return nil, err
}
if resp.StatusCode != 200 {
return nil, fmt.Errorf("Request to %s failed with %s", endpoint, resp.Status)
}
tree, err := html.Parse(resp.Body)
if err != nil {
return nil, err
Expand Down

0 comments on commit 91c21f5

Please sign in to comment.