mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-16 03:49:52 +00:00
fix: report http error if /api call fails
Previously it would try to run the JSON decoder on a string like "404 not found" and report that failing.
This commit is contained in:
@@ -192,6 +192,9 @@ func (c *appClient) Details() (xfer.Details, error) {
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return result, fmt.Errorf("Error response from %s: %s", c.url("/api"), resp.Status)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if err := codec.NewDecoder(resp.Body, &codec.JsonHandle{}).Decode(&result); err != nil {
|
||||
return result, err
|
||||
|
||||
Reference in New Issue
Block a user