From 72c922668fefc1cf671d9c9e38ebf22a22a80dcf Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Wed, 12 Nov 2014 13:31:24 -0800 Subject: [PATCH] Improve error reporting --- pkg/client/request.go | 6 +++++- pkg/kubectl/cmd/cmd.go | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/client/request.go b/pkg/client/request.go index c43dcc47314..84fe5a62487 100644 --- a/pkg/client/request.go +++ b/pkg/client/request.go @@ -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 } diff --git a/pkg/kubectl/cmd/cmd.go b/pkg/kubectl/cmd/cmd.go index 60c41b0f2b6..d33f1ee0e3a 100644 --- a/pkg/kubectl/cmd/cmd.go +++ b/pkg/kubectl/cmd/cmd.go @@ -106,11 +106,9 @@ Find more information at https://github.com/GoogleCloudPlatform/kubernetes.`, } } -// TODO: remove this function and references to it-- errors it prints are -// very unhelpful because file/line number are wrong. func checkErr(err error) { if err != nil { - glog.Fatalf("%v", err) + glog.FatalDepth(1, err) } }