diff options
author | Collin Guarino <collin.guarino@gmail.com> | 2016-02-21 16:00:31 -0500 |
---|---|---|
committer | Collin Guarino <collin.guarino@gmail.com> | 2016-02-21 16:00:31 -0500 |
commit | 6b8ed19f09439a1d8af9129143ebf96a4c3b8774 (patch) | |
tree | 3ee56396de620e802bac083cc1674d7154060816 | |
parent | 8ae87462cebfa392efe0b3c951eb9d385c7c41bd (diff) |
Implemented error catching on GetAllLights if no lights are found.
-rw-r--r-- | bridge.go | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -221,10 +221,15 @@ func (bridge *Bridge) GetAllLights() ([]Light, error) { for index := 1; index < 101; index++ { light, err := bridge.GetLightByIndex(index) if err != nil { - break + break // Final light index reached, index does not exist. } lights = append(lights, light) } + if len(lights) == 0 { + err := errors.New("Error: No lights found by GetAllLights.") + log.Println(err) + return lights, err + } return lights, nil } |