Return error on error reply.

This commit is contained in:
David Newhall II 2019-06-18 23:38:18 -07:00
parent 70783bb1b0
commit 9ca669fe59
1 changed files with 3 additions and 0 deletions

View File

@ -157,6 +157,9 @@ func (u *Unifi) GetData(methodPath string, v interface{}) error {
} else if err = json.Unmarshal(body, v); err != nil { } else if err = json.Unmarshal(body, v); err != nil {
return errors.Wrapf(err, "json.Unmarshal(%s)", methodPath) return errors.Wrapf(err, "json.Unmarshal(%s)", methodPath)
} }
if resp.StatusCode != http.StatusOK {
return errors.Errorf("invalid status code from server %v %v", resp.StatusCode, resp.Status)
}
return nil return nil
} }