Skip to content

Commit

Permalink
use the main branch's implementation of MultiError
Browse files Browse the repository at this point in the history
Signed-off-by: Yash Sharma <[email protected]>
  • Loading branch information
yashrsharma44 committed Mar 11, 2021
1 parent 7b0492f commit b05c9fd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
5 changes: 0 additions & 5 deletions pkg/errutil/multierror.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ func (es MultiError) Err() error {
return NonNilMultiError(es)
}

// Error implements the error interface.
func (es MultiError) Error() string {
return es.Err().Error()
}

type NonNilMultiError MultiError

// Returns a concatenated string of the contained errors.
Expand Down
2 changes: 1 addition & 1 deletion pkg/route/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func determineWriteErrorCause(err error, threshold int) error {
}

unwrappedErr := errors.Cause(err)
errs, ok := unwrappedErr.(errutil.MultiError)
errs, ok := unwrappedErr.(errutil.NonNilMultiError)
if !ok {
errs = []error{unwrappedErr}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/route/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func (h *Handler) fanoutForward(pctx context.Context, tenant string, replicas ma
return fctx.Err()
case err, more := <-ec:
if !more {
return errs
return errs.Err()
}
if err == nil {
success++
Expand Down
26 changes: 13 additions & 13 deletions pkg/route/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestDetermineWriteErrorCause(t *testing.T) {
},
{
name: "nil multierror",
err: errutil.MultiError([]error{}),
err: errutil.NonNilMultiError([]error{}),
},
{
name: "matching simple",
Expand All @@ -59,15 +59,15 @@ func TestDetermineWriteErrorCause(t *testing.T) {
},
{
name: "non-matching multierror",
err: errutil.MultiError([]error{
err: errutil.NonNilMultiError([]error{
errors.New("foo"),
errors.New("bar"),
}),
exp: errors.New("2 errors: foo; bar"),
},
{
name: "nested non-matching multierror",
err: errors.Wrap(errutil.MultiError([]error{
err: errors.Wrap(errutil.NonNilMultiError([]error{
errors.New("foo"),
errors.New("bar"),
}), "baz"),
Expand All @@ -76,9 +76,9 @@ func TestDetermineWriteErrorCause(t *testing.T) {
},
{
name: "deep nested non-matching multierror",
err: errors.Wrap(errutil.MultiError([]error{
err: errors.Wrap(errutil.NonNilMultiError([]error{
errors.New("foo"),
errutil.MultiError([]error{
errutil.NonNilMultiError([]error{
errors.New("bar"),
errors.New("qux"),
}),
Expand All @@ -88,7 +88,7 @@ func TestDetermineWriteErrorCause(t *testing.T) {
},
{
name: "matching multierror",
err: errutil.MultiError([]error{
err: errutil.NonNilMultiError([]error{
storage.ErrOutOfOrderSample,
errors.New("foo"),
errors.New("bar"),
Expand All @@ -98,7 +98,7 @@ func TestDetermineWriteErrorCause(t *testing.T) {
},
{
name: "matching but below threshold multierror",
err: errutil.MultiError([]error{
err: errutil.NonNilMultiError([]error{
storage.ErrOutOfOrderSample,
errors.New("foo"),
errors.New("bar"),
Expand All @@ -108,7 +108,7 @@ func TestDetermineWriteErrorCause(t *testing.T) {
},
{
name: "matching multierror many",
err: errutil.MultiError([]error{
err: errutil.NonNilMultiError([]error{
storage.ErrOutOfOrderSample,
errConflict,
status.Error(codes.AlreadyExists, "conflict"),
Expand All @@ -120,7 +120,7 @@ func TestDetermineWriteErrorCause(t *testing.T) {
},
{
name: "matching multierror many, one above threshold",
err: errutil.MultiError([]error{
err: errutil.NonNilMultiError([]error{
storage.ErrOutOfOrderSample,
errConflict,
tsdb.ErrNotReady,
Expand All @@ -133,7 +133,7 @@ func TestDetermineWriteErrorCause(t *testing.T) {
},
{
name: "matching multierror many, both above threshold, conflict have precedence",
err: errutil.MultiError([]error{
err: errutil.NonNilMultiError([]error{
storage.ErrOutOfOrderSample,
errConflict,
tsdb.ErrNotReady,
Expand All @@ -147,7 +147,7 @@ func TestDetermineWriteErrorCause(t *testing.T) {
},
{
name: "nested matching multierror",
err: errors.Wrap(errors.Wrap(errutil.MultiError([]error{
err: errors.Wrap(errors.Wrap(errutil.NonNilMultiError([]error{
storage.ErrOutOfOrderSample,
errors.New("foo"),
errors.New("bar"),
Expand All @@ -157,8 +157,8 @@ func TestDetermineWriteErrorCause(t *testing.T) {
},
{
name: "deep nested matching multierror",
err: errors.Wrap(errutil.MultiError([]error{
errutil.MultiError([]error{
err: errors.Wrap(errutil.NonNilMultiError([]error{
errutil.NonNilMultiError([]error{
errors.New("qux"),
status.Error(codes.AlreadyExists, "conflict"),
status.Error(codes.AlreadyExists, "conflict"),
Expand Down

0 comments on commit b05c9fd

Please sign in to comment.