Fix: missing status code check for Windscribe API

This commit is contained in:
Quentin McGaw (desktop)
2021-09-08 16:09:32 +00:00
parent 45ce422a89
commit 9afe455635

View File

@@ -56,6 +56,11 @@ func fetchAPI(ctx context.Context, client *http.Client) (
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
return data, fmt.Errorf("%w: %d %s", ErrHTTPStatusCodeNotOK,
response.StatusCode, response.Status)
}
decoder := json.NewDecoder(response.Body)
if err := decoder.Decode(&data); err != nil {
return data, fmt.Errorf("%w: %s", ErrUnmarshalResponseBody, err)