From 74bc3c6242f8696553aa2529767219ede1ff47ad Mon Sep 17 00:00:00 2001 From: Michael Daffin Date: Mon, 5 Sep 2016 15:56:09 +0100 Subject: [PATCH] Add check for ErrIterOver in BranchIterator.ForEach The BranchIterator.ForEach currently returns the ErrIterOver error if no error had occured during the iteration. This leads to a rather unhelpful blank error message with the error code -31 when iterating over the branches. This commit adds a check for ErrIterOver at the end of the ForEach method so that the client code only has to worry about checking for nil as apose to checking for the ErrIterOver error. --- branch.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/branch.go b/branch.go index a869054..d381c23 100644 --- a/branch.go +++ b/branch.go @@ -73,6 +73,10 @@ func (i *BranchIterator) ForEach(f BranchIteratorFunc) error { } } + if err != nil && IsErrorCode(err, ErrIterOver) { + return nil + } + return err } -- 2.45.2