Skip to content

Commit

Permalink
Adding extra logging to cAdvisor client errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarmol committed Jan 22, 2015
1 parent 8f0f229 commit eb6f9a9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,22 @@ func (self *Client) httpGetJsonData(data, postData interface{}, url, infoName st
resp, err = http.Get(url)
}
if err != nil {
return fmt.Errorf("unable to get %q: %v", infoName, err)
return fmt.Errorf("unable to get %q from %q: %v", infoName, url, err)
}
if resp == nil {
return fmt.Errorf("received empty response from %q", infoName)
return fmt.Errorf("received empty response for %q from %q", infoName, url)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
err = fmt.Errorf("unable to read all %q: %v", infoName, err)
err = fmt.Errorf("unable to read all %q from %q: %v", infoName, url, err)
return err
}
if resp.StatusCode != 200 {
return fmt.Errorf("request failed with error: %q", strings.TrimSpace(string(body)))
return fmt.Errorf("request %q failed with error: %q", url, strings.TrimSpace(string(body)))
}
if err = json.Unmarshal(body, data); err != nil {
err = fmt.Errorf("unable to unmarshal %q (Body: %q) with error: %v", infoName, string(body), err)
err = fmt.Errorf("unable to unmarshal %q (Body: %q) from %q with error: %v", infoName, string(body), url, err)
return err
}
return nil
Expand Down

0 comments on commit eb6f9a9

Please sign in to comment.