Skip to content

Commit

Permalink
errors: multierror returns original error on single error
Browse files Browse the repository at this point in the history
  • Loading branch information
cezarsa committed Nov 24, 2017
1 parent 3c68fa8 commit 3ccdfef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion errors/errors.go
Expand Up @@ -64,9 +64,12 @@ func (m *MultiError) Len() int {
}

func (m *MultiError) ToError() error {
if len(m.errors) == 0 {
if m.Len() == 0 {
return nil
}
if m.Len() == 1 {
return m.errors[0]
}
return m
}

Expand Down
2 changes: 1 addition & 1 deletion healer/healer_node_test.go
Expand Up @@ -192,7 +192,7 @@ func (s *S) TestHealerHealNodeRemoveError(c *check.C) {
p.PrepareFailure("RemoveNode", fmt.Errorf("remove node error 2"))

created, err := healer.healNode(nodes[0])
c.Assert(err, check.ErrorMatches, `(?s).*remove node error.*Unable to remove node http://addr1:1 from provisioner.*`)
c.Assert(err, check.ErrorMatches, `(?s)Unable to remove node http://addr1:1 from provisioner.*remove node error.*`)
c.Assert(created.Address, check.Equals, "http://addr2:2")
nodes, err = p.ListNodes(nil)
c.Assert(err, check.IsNil)
Expand Down

0 comments on commit 3ccdfef

Please sign in to comment.