From b24917993ec963f45d186ec1b7d45d0eb20e8958 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sun, 6 Oct 2019 17:27:46 +0000 Subject: [PATCH] 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. --- probe/appclient/app_client.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/probe/appclient/app_client.go b/probe/appclient/app_client.go index 1912019b4..3c04e4e40 100644 --- a/probe/appclient/app_client.go +++ b/probe/appclient/app_client.go @@ -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