From 536153342e988d98e4001782b15d139fc3987368 Mon Sep 17 00:00:00 2001 From: Kelsey Hightower Date: Fri, 19 Feb 2016 15:51:57 -0800 Subject: [PATCH] Capture and return errors during watches on consul Before this change consul errors were not returned correctly during watches. Resolved the issue by returning the initial watch index and error and avoid the nil pointer dereference. Fixes #322 --- backends/consul/client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backends/consul/client.go b/backends/consul/client.go index b611ebf21..a50f3188e 100644 --- a/backends/consul/client.go +++ b/backends/consul/client.go @@ -83,6 +83,10 @@ func (c *ConsulClient) WatchPrefix(prefix string, waitIndex uint64, stopChan cha WaitIndex: waitIndex, } _, meta, err := c.client.List(prefix, &opts) + if err != nil { + respChan <- watchResponse{waitIndex, err} + return + } respChan <- watchResponse{meta.LastIndex, err} }() for {