resolves issues where failed api calls lead to obscure errors (#7051)
This commit is contained in:
@@ -97,6 +97,7 @@ func (f *Fibaro) getJSON(path string, dataStruct interface{}) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
err = fmt.Errorf("Response from url \"%s\" has status code %d (%s), expected %d (%s)",
|
||||
@@ -108,8 +109,6 @@ func (f *Fibaro) getJSON(path string, dataStruct interface{}) error {
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
err = dec.Decode(&dataStruct)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user