Improve error reporting

This commit is contained in:
Daniel Smith
2014-11-12 13:31:24 -08:00
parent 4e1ab8045b
commit 72c922668f
2 changed files with 6 additions and 4 deletions

View File

@@ -278,7 +278,11 @@ func (r *Request) Watch() (watch.Interface, error) {
return nil, err
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("Got status: %v", resp.StatusCode)
var body []byte
if resp.Body != nil {
body, _ = ioutil.ReadAll(resp.Body)
}
return nil, fmt.Errorf("For request '%v', got status: %v\nbody: %v", req.URL, resp.StatusCode, string(body))
}
return watch.NewStreamWatcher(watchjson.NewDecoder(resp.Body, r.codec)), nil
}