Fix panic when influx client receives error status code
parent
2ef4a7b13d
commit
7d95840956
|
@ -59,6 +59,9 @@ func query(u *url.URL, q mrfusion.Query) (mrfusion.Response, error) {
|
|||
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)
|
||||
|
@ -73,6 +76,7 @@ func query(u *url.URL, q mrfusion.Query) (mrfusion.Response, error) {
|
|||
if decErr != nil {
|
||||
return nil, fmt.Errorf("unable to decode json: received status code %d err: %s", resp.StatusCode, decErr)
|
||||
}
|
||||
|
||||
// If we don't have an error in our json response, and didn't get statusOK
|
||||
// then send back an error
|
||||
if resp.StatusCode != http.StatusOK && response.Err != "" {
|
||||
|
|
Loading…
Reference in New Issue