pkg / errors

Simple error handling primitives
https://godoc.org/github.com/pkg/errors
BSD 2-Clause "Simplified" License
8.18k stars 691 forks source link

func Is() does not works with errors.Wrap or errors.Wrapf #218

Closed waichee closed 4 years ago

waichee commented 4 years ago

Checking of a error type in the error chain only works for errors wrapped with fmt.Errorf fmt.Errorf("some %w", err)

Errors wrapped with errors.Wrap(err, "some stuff") does not work when being checked with

var specialError = errors.New("defined type error")

err1 := fmt.Errorf("some %w", specialError)

err2 := errors.Wrap(specialError, "some stuff")

// this works
errors.Is(err1, specialError) 

// this doesnt work
errors.Is(err2, specialError) 
puellanivis commented 4 years ago

Which version of the errors package are you using? If you are not using the latest master branch (so, you’re using 0.8.1 or any other release) then the package is incompatible with the standard errors library.

We are working on cutting a new release that will be compatible with standard errors package expansions. But it’s kind of slow going as everything is done by volunteers.

waichee commented 4 years ago

ah master branch works! thanks

aperezg commented 4 years ago

Now also in a new v0.9.0 release