aboutsummaryrefslogtreecommitdiff
path: root/bridge.go
diff options
context:
space:
mode:
authorCollin Guarino <collin.guarino@gmail.com>2016-02-21 16:00:31 -0500
committerCollin Guarino <collin.guarino@gmail.com>2016-02-21 16:00:31 -0500
commit6b8ed19f09439a1d8af9129143ebf96a4c3b8774 (patch)
tree3ee56396de620e802bac083cc1674d7154060816 /bridge.go
parent8ae87462cebfa392efe0b3c951eb9d385c7c41bd (diff)
Implemented error catching on GetAllLights if no lights are found.
Diffstat (limited to 'bridge.go')
-rw-r--r--bridge.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/bridge.go b/bridge.go
index 6b781c1..f78b8e3 100644
--- a/bridge.go
+++ b/bridge.go
@@ -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
}