Improve error messages through proxy
Previously, the proxy would only report the error code it received from an InfluxDB instance. This also passes the error message returned by InfluxDB through, so it appears in the Chronograf server logs as well as in the response returned to the frontend by the proxy (making it visible by inspecting the request in the network tab).pull/672/head
parent
06cdd47d47
commit
c1effd7f47
|
@ -70,14 +70,15 @@ func (c *Client) query(u *url.URL, q chronograf.Query) (chronograf.Response, err
|
|||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("received status code %d from server", resp.StatusCode)
|
||||
}
|
||||
|
||||
var response Response
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
decErr := dec.Decode(&response)
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("received status code %d from server: err: %s", resp.StatusCode, response.Err)
|
||||
}
|
||||
|
||||
// ignore this error if we got an invalid status code
|
||||
if decErr != nil && decErr.Error() == "EOF" && resp.StatusCode != http.StatusOK {
|
||||
decErr = nil
|
||||
|
|
Loading…
Reference in New Issue