summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Daffin <[email protected]>2016-09-05 15:56:09 +0100
committerMichael Daffin <[email protected]>2016-09-05 15:56:09 +0100
commit74bc3c6242f8696553aa2529767219ede1ff47ad (patch)
tree354d24c6beddf250e7be954584fa5e3eabdc863d
parent241aa34d83b210ceaab7029c46e05794f2ea9797 (diff)
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.
-rw-r--r--branch.go4
1 files changed, 4 insertions, 0 deletions
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
}