Commit 247bc721 authored by David Symonds's avatar David Symonds

misc/dashboard/codereview: better debugging when some fetches fail.

R=rsc
CC=golang-dev
https://golang.org/cl/7836045
parent e3c7a9db
...@@ -178,8 +178,14 @@ func handleAssign(w http.ResponseWriter, r *http.Request) { ...@@ -178,8 +178,14 @@ func handleAssign(w http.ResponseWriter, r *http.Request) {
return return
} }
defer resp.Body.Close() defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
c.Errorf("Failed reading body: %v", err)
http.Error(w, err.Error(), 500)
return
}
if resp.StatusCode != 200 { if resp.StatusCode != 200 {
c.Errorf("Retrieving CL reviewer list failed: got HTTP response %d", resp.StatusCode) c.Errorf("Retrieving CL reviewer list failed: got HTTP response %d\nBody: %s", resp.StatusCode, body)
http.Error(w, "Failed contacting Rietveld", 500) http.Error(w, "Failed contacting Rietveld", 500)
return return
} }
...@@ -187,7 +193,7 @@ func handleAssign(w http.ResponseWriter, r *http.Request) { ...@@ -187,7 +193,7 @@ func handleAssign(w http.ResponseWriter, r *http.Request) {
var apiResp struct { var apiResp struct {
Reviewers []string `json:"reviewers"` Reviewers []string `json:"reviewers"`
} }
if err := json.NewDecoder(resp.Body).Decode(&apiResp); err != nil { if err := json.Unmarshal(body, &apiResp); err != nil {
// probably can't be retried // probably can't be retried
msg := fmt.Sprintf("Malformed JSON from %v: %v", url, err) msg := fmt.Sprintf("Malformed JSON from %v: %v", url, err)
c.Errorf("%s", msg) c.Errorf("%s", msg)
...@@ -212,8 +218,14 @@ func handleAssign(w http.ResponseWriter, r *http.Request) { ...@@ -212,8 +218,14 @@ func handleAssign(w http.ResponseWriter, r *http.Request) {
return return
} }
defer resp.Body.Close() defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
c.Errorf("Failed reading Gobot body: %v", err)
http.Error(w, err.Error(), 500)
return
}
if resp.StatusCode != 200 { if resp.StatusCode != 200 {
c.Errorf("Gobot GET failed: got HTTP response %d", resp.StatusCode) c.Errorf("Gobot GET failed: got HTTP response %d\nBody: %s", resp.StatusCode, body)
http.Error(w, "Failed contacting Gobot", 500) http.Error(w, "Failed contacting Gobot", 500)
return return
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment