vendor
This commit is contained in:
21
vendor/github.com/crewjam/errset/README.md
generated
vendored
Normal file
21
vendor/github.com/crewjam/errset/README.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
errset is a trivial golang package that implements a slice of errors.
|
||||
|
||||
[](https://travis-ci.org/crewjam/errset)
|
||||
|
||||
[](http://godoc.org/github.com/crewjam/errset)
|
||||
|
||||
The typical go idiom is to return an `error` or a tuple of (thing, `error`) from functions. This works well if a function performs exactly one task, but
|
||||
when a function does work which can reasonably partially fail, I found myself writing the same code over and over again. For example:
|
||||
|
||||
// CommitBatch commits as many things as it can.
|
||||
func CommitBatch(things []Thing) error {
|
||||
errs := errset.ErrSet{}
|
||||
for _, thing := range things {
|
||||
err := Commit(thing)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
return errs.ReturnValue() // nil if there were no errors
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user