Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unrecoverableError cannot be unwrapped with errors.Is() #50

Closed
everactivejack opened this issue Oct 28, 2021 · 0 comments · Fixed by #59
Closed

unrecoverableError cannot be unwrapped with errors.Is() #50

everactivejack opened this issue Oct 28, 2021 · 0 comments · Fixed by #59

Comments

@everactivejack
Copy link

See example (https://play.golang.org/p/SFwoFoqUi_h):

package main

import (
	"fmt"
	retry "github.com/avast/retry-go/v3"
	"github.com/pkg/errors"
)

var ErrTest = errors.New("test")

func main() {
	err := retry.Unrecoverable(ErrTest)
	err2 := fmt.Errorf("wrapping: %w",ErrTest)
	
	fmt.Println(errors.Is(err,ErrTest))
	fmt.Println(errors.Is(err2,ErrTest))
}

Outputs:

false
true

I think this just means that the errUnrecoverable needs to implement Unwrap(), which should be a pretty simple change of adding (see https://play.golang.org/p/LpiCrGbpEOD)

func (u unrecoverableError) Unwrap() error {
	return u.error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant