From f79ea1df5d908f8473798b81bd4cddd455f0e8e8 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sun, 18 Apr 2021 15:42:17 +0000 Subject: [PATCH] Handle API error in validateColor --- color.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/color.go b/color.go index 09f65c7..accb926 100644 --- a/color.go +++ b/color.go @@ -209,6 +209,10 @@ func (c *Client) ValidateColor(color Color) (Color, error) { defer resp.Body.Close() + if resp.IsError() { + return nil, resp.GetLifxError() + } + if err = json.NewDecoder(resp.Body).Decode(&s); err != nil { return nil, err }