From 4e7064023f904165889f672d9ce77903be49b08b Mon Sep 17 00:00:00 2001 From: James Phillips Date: Thu, 23 Mar 2017 20:04:39 -0700 Subject: [PATCH] Makes WaitForResult always return an error if it times out. --- testutil/wait.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/testutil/wait.go b/testutil/wait.go index 7ecb74f180..9854f15cd1 100644 --- a/testutil/wait.go +++ b/testutil/wait.go @@ -6,10 +6,10 @@ import ( "time" "github.com/hashicorp/consul/consul/structs" + "github.com/pkg/errors" ) type testFn func() (bool, error) -type errorFn func(error) const ( baseWait = 1 * time.Millisecond @@ -33,8 +33,11 @@ func WaitForResult(try testFn) error { wait = maxWait } } - - return err + if err != nil { + return errors.Wrap(err, "timed out with error") + } else { + return fmt.Errorf("timed out") + } } type rpcFn func(string, interface{}, interface{}) error