util/multierr: new package

github.com/go-multierror/multierror served us well.
But we need a few feature from it (implement Is),
and it's not worth maintaining a fork of such a small module.

Instead, I did a clean room implementation inspired by its API.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder
2021-11-02 14:30:48 -07:00
committed by Josh Bleecher Snyder
parent 17b5782b3a
commit 3fd5f4380f
14 changed files with 186 additions and 19 deletions

View File

@@ -16,8 +16,8 @@ import (
"sync/atomic"
"time"
"github.com/go-multierror/multierror"
"tailscale.com/tailcfg"
"tailscale.com/util/multierr"
)
var (
@@ -268,7 +268,7 @@ func selfCheckLocked() {
// OverallError returns a summary of the health state.
//
// If there are multiple problems, the error will be of type
// multierror.MultipleErrors.
// multierr.Error.
func OverallError() error {
mu.Lock()
defer mu.Unlock()
@@ -337,7 +337,7 @@ func overallErrorLocked() error {
// Not super efficient (stringifying these in a sort), but probably max 2 or 3 items.
return errs[i].Error() < errs[j].Error()
})
return multierror.New(errs)
return multierr.New(errs...)
}
var (