mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-18 02:48:40 +00:00
util/multierr: implement Go 1.20+'s multiple error Unwrap
Now that Go 1.20 is released, multierr.Error can implement Unwrap() []error Updates #7123 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: Ic28c2579de6799801836c447afbca8cdcba732cf
This commit is contained in:
parent
5ba2543828
commit
2dc3dc21a8
@ -33,15 +33,12 @@ func (e Error) Errors() []error {
|
||||
return slices.Clone(e.errs)
|
||||
}
|
||||
|
||||
// TODO(https://go.dev/cl/53435): Implement Unwrap when Go 1.20 is released.
|
||||
/*
|
||||
// Unwrap returns the underlying errors as is.
|
||||
// Unwrap returns the underlying errors as-is.
|
||||
func (e Error) Unwrap() []error {
|
||||
// Do not clone since Unwrap requires callers to not mutate the slice.
|
||||
// See the documentation in the Go "errors" package.
|
||||
return e.errs
|
||||
}
|
||||
*/
|
||||
|
||||
// New returns an error composed from errs.
|
||||
// Some errors in errs get special treatment:
|
||||
@ -135,13 +132,6 @@ func Range(err error, fn func(error) bool) bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
// TODO(https://go.dev/cl/53435): Delete this when Error implements Unwrap.
|
||||
case Error:
|
||||
for _, err := range err.errs {
|
||||
if !Range(err, fn) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user