Skip to content

Commit

Permalink
Merge pull request #18 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 1.4.3
  • Loading branch information
andyone committed Jan 19, 2016
2 parents 7527f47 + c1c0a91 commit 2e3643b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

#### v1.4.3

* `[errutil]` Improved Add method

#### v1.4.2

* `[fsutil]` Added method `ProperPath` which return first proper path from given slice
Expand Down
10 changes: 7 additions & 3 deletions errutil/errutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ func NewErrors() *Errors {
// ////////////////////////////////////////////////////////////////////////////////// //

// Add adds new error to slice
func (e *Errors) Add(err error) *Errors {
if err == nil {
func (e *Errors) Add(errs ...error) *Errors {
if errs == nil || len(errs) == 0 {
return e
}

e.errors = append(e.errors, err)
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 2e3643b

Please sign in to comment.