Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion multi/multi_error.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package multi

import (
"errors"
"strings"

"github.com/upfluence/errors/base"
Expand Down Expand Up @@ -80,7 +81,7 @@

func Combine(errs ...error) error { return Wrap(errs) }

type MultiError interface {

Check failure on line 84 in multi/multi_error.go

View workflow job for this annotation

GitHub Actions / runner / golangci-lint

exported: type name will be used as multi.MultiError by other packages, and that stutters; consider calling this Error (revive)
Errors() []error
}

Expand All @@ -103,7 +104,7 @@

errs := ExtractErrors(nerr)

if len(errs) == 1 && errs[0] == nerr {
if len(errs) == 1 && errors.Is(errs[0], nerr) {
return []error{err}
}

Expand Down
20 changes: 20 additions & 0 deletions multi/multi_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ func TestCombining(t *testing.T) {
},
want: multi.Combine(foo, foo, foo),
},
{
errs: []error{
errors.WithStack(notComparableError{s: []string{"foo"}}),
errors.Combine(
notComparableError{s: []string{"bar"}},
notComparableError{s: []string{"buz"}},
),
},
want: multi.Combine(
notComparableError{s: []string{"foo"}},
notComparableError{s: []string{"bar"}},
notComparableError{s: []string{"buz"}},
),
},
} {
assert.Equal(t, tt.want, errors.Cause(errors.WrapErrors(tt.errs)))
}
Expand All @@ -55,3 +69,9 @@ func TestTags(t *testing.T) {
tags.GetTags(err),
)
}

type notComparableError struct {
s []string
}

func (notComparableError) Error() string { return "not comparable" }
Loading