Skip to content

Commit

Permalink
improve error handling on non-ok response
Browse files Browse the repository at this point in the history
Signed-off-by: Friedrich Albert Kyuri <[email protected]>
  • Loading branch information
Friedrich Albert Kyuri committed Mar 12, 2022
1 parent 8c85751 commit 86f75be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/scalers/metrics_api_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ func (s *metricsAPIScaler) getMetricValue(ctx context.Context) (*resource.Quanti
if err != nil {
return nil, err
}
defer r.Body.Close()

if r.StatusCode != http.StatusOK {
msg := fmt.Sprintf("api returned %d", r.StatusCode)
msg := fmt.Sprintf("%s: api returned %d", r.Request.URL.String(), r.StatusCode)
return nil, errors.New(msg)
}

defer r.Body.Close()
b, err := ioutil.ReadAll(r.Body)
if err != nil {
return nil, err
Expand Down

0 comments on commit 86f75be

Please sign in to comment.