Skip to content

Commit

Permalink
Remove aggregate struct (#2213)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu authored Oct 25, 2023
1 parent 128757d commit cd77a1e
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions utils/wrappers/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

package wrappers

import "strings"

var _ error = (*aggregate)(nil)

type Errs struct{ Err error }

func (errs *Errs) Errored() bool {
Expand All @@ -23,28 +19,3 @@ func (errs *Errs) Add(errors ...error) {
}
}
}

// NewAggregate returns an aggregate error from a list of errors
func NewAggregate(errs []error) error {
err := &aggregate{errs}
if len(err.Errors()) == 0 {
return nil
}
return err
}

type aggregate struct{ errs []error }

// Error returns the slice of errors with comma separated messsages wrapped in brackets
// [ error string 0 ], [ error string 1 ] ...
func (a *aggregate) Error() string {
errString := make([]string, len(a.errs))
for i, err := range a.errs {
errString[i] = "[" + err.Error() + "]"
}
return strings.Join(errString, ",")
}

func (a *aggregate) Errors() []error {
return a.errs
}

0 comments on commit cd77a1e

Please sign in to comment.