go-errors / errors

errors with stacktraces for go
https://godoc.org/github.com/go-errors/errors
MIT License
935 stars 93 forks source link

Add "As" of standard errors module #31

Closed waschik closed 3 years ago

waschik commented 4 years ago

Starting with go the errors package has an "As" method for getting wrapped errors. In go 1.13 implementation could forward simply to standard package. I tried to implement this also in pre 1.13 with reflection. The merge request contains also two changes caused by running gofmt.

Tested with go1.15.2 and go1.10.4.

PS: I needed this for finding the error type (ErrHelp) in an error for github.com/jessevdk/go-flags

agis commented 3 years ago

Any news on this one? We also want to be able to use the standard library errors.As() with errors created with go-errors/errors.Errorf so this would be very helpful to us.

ConradIrwin commented 3 years ago

Thanks for the reminder, and sorry for missing this.

The code change seems reasonable to me, merging!