Add error handling for ForEach's.

This commit is contained in:
Andrey Smirnov
2013-12-26 16:58:04 +04:00
parent be7a1762ac
commit 218057ea48
9 changed files with 151 additions and 40 deletions
+7 -2
View File
@@ -162,8 +162,13 @@ func (collection *SnapshotCollection) ByName(name string) (*Snapshot, error) {
}
// ForEach runs method for each snapshot
func (collection *SnapshotCollection) ForEach(handler func(*Snapshot)) {
func (collection *SnapshotCollection) ForEach(handler func(*Snapshot) error) error {
var err error
for _, s := range collection.list {
handler(s)
err = handler(s)
if err != nil {
return err
}
}
return err
}