errors icon indicating copy to clipboard operation
errors copied to clipboard

`WalkDeep` cannot walk vertical subtrees

Open YuJuncen opened this issue 1 year ago • 0 comments

Give an tree of errors:

A + B - C
  |
  + D - E

For now WalkDeep walks A and multierr(B-C, D-E) and then returns. It isn't deep enough.

An example of this:

func TestErr(t *testing.T) {
	serr := backup.MakeStoreBasedErr(42, multierr.Combine(
		errors.Annotate(berrors.ErrFailedToConnect, "oops"),
		berrors.ErrFailedToConnect.GenWithStack("whoa")))
	require.True(t, berrors.Is(serr, berrors.ErrFailedToConnect))
}

Where StoreBasedErr is a wrapper of an err and implements Unwrap to its inner error, berrors.Is is simply:

func Is(err error, is *errors.Error) bool {
	errorFound := errors.Find(err, func(e error) bool {
		normalizedErr, ok := e.(*errors.Error)
		return ok && normalizedErr.ID() == is.ID()
	})
	return errorFound != nil
}

This testcase fails.

Image

YuJuncen avatar Dec 17 '24 09:12 YuJuncen