From 9ca669fe59ef77e7caae433deebcf90b3fb93270 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 18 Jun 2019 23:38:18 -0700 Subject: [PATCH] Return error on error reply. --- core/unifi/unifi.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/unifi/unifi.go b/core/unifi/unifi.go index 39a08282..e41348ff 100644 --- a/core/unifi/unifi.go +++ b/core/unifi/unifi.go @@ -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 }