Skip to content

Commit

Permalink
Improved errutil package
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Jan 19, 2016
1 parent ef60fc0 commit c1c0a91
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion errutil/errutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ func (e *Errors) Add(errs ...error) *Errors {
return e
}

e.errors = append(e.errors, errs...)
for _, err := range errs {
if err != nil {
e.errors = append(e.errors, err)
}
}

return e
}
Expand Down
2 changes: 2 additions & 0 deletions errutil/errutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ var _ = Suite(&ErrSuite{})
func (s *ErrSuite) TestPositive(c *C) {
errs := NewErrors()

errs.Add()
errs.Add(nil)
errs.Add(errors.New("1"))
errs.Add(errors.New("2"))
errs.Add(errors.New("3"))
Expand Down

0 comments on commit c1c0a91

Please sign in to comment.