Return error on error reply.
This commit is contained in:
parent
70783bb1b0
commit
9ca669fe59
|
|
@ -157,6 +157,9 @@ func (u *Unifi) GetData(methodPath string, v interface{}) error {
|
|||
} else if err = json.Unmarshal(body, v); err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue