Skip to content

Commit

Permalink
Rename to Chain because it makes more clear that the errors are sti…
Browse files Browse the repository at this point in the history
…ll wrapped
  • Loading branch information
muXxer committed Mar 14, 2024
1 parent 8b0b59e commit 13cbd70
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions ierrors/ierrors_no_stacktrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ func Join(errs ...error) error {
return errors.Join(errs...)
}

// Merge merges multiple errors into a single error by wrapping them.
// Chain chains multiple errors into a single error by wrapping them.
// Any nil error values are discarded.
// Merge returns nil if every value in errs is nil.
// Merge adds a stacktrace to the error if there was no stacktrace
// Chain returns nil if every value in errs is nil.
// Chain adds a stacktrace to the error if there was no stacktrace
// in the error tree yet and if the build flag "stacktrace" is set.
func Merge(errs ...error) error {
func Chain(errs ...error) error {
var result error
for _, err := range errs {
if err == nil {
Expand Down
8 changes: 4 additions & 4 deletions ierrors/ierrors_stacktrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ func Join(errs ...error) error {
return ensureStacktraceUniqueness(errors.Join(errs...))
}

// Merge merges multiple errors into a single error by wrapping them.
// Chain chains multiple errors into a single error by wrapping them.
// Any nil error values are discarded.
// Merge returns nil if every value in errs is nil.
// Merge adds a stacktrace to the error if there was no stacktrace
// Chain returns nil if every value in errs is nil.
// Chain adds a stacktrace to the error if there was no stacktrace
// in the error tree yet and if the build flag "stacktrace" is set.
func Merge(errs ...error) error {
func Chain(errs ...error) error {
var result error
for _, err := range errs {
if err == nil {
Expand Down
2 changes: 1 addition & 1 deletion ierrors/ierrors_stacktrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ func TestErrors(t *testing.T) {
err15 := WithStack(errStacktrace)
require.Equal(t, 1, strings.Count(err15.Error(), "github.com/iotaledger/hive.go/ierrors.TestErrors"))

err16 := Merge(New("err16"), New("merged"))
err16 := Chain(New("err16"), New("chained"))
require.Equal(t, 1, strings.Count(err16.Error(), "github.com/iotaledger/hive.go/ierrors.TestErrors"))
}

0 comments on commit 13cbd70

Please sign in to comment.