Generally, I would argue that the grpc package maintainers should, at some point, support native wrapping of errors. In the meantime, they are providing this package: https://pkg.go.dev/google.golang.org/grpc/status It predates (by a long time) the errors.Is APIs, which is why I assume they haven't yet implemented support
On Sat, May 15, 2021 at 1:47 PM cpu...@gmail.com <cpui...@gmail.com> wrote: > In my local code, I'm using things like > > if errors.Is(err, api.ErrMustRetry) { ... } > > How would I achieve the same on errors returned by the gRCP interface? > I've noticed these are wrapped: > > rpc error: code = Unknown desc = must retry rpc error: code = Unknown desc > = must retry > > I assume the errors package won't work here as type information is not > carried across gRPC: What is the best practice here: unwrap the root error > from the RPC result (how) and perform string comparison? > > Thanks, > Andreas > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/c3053cb0-d739-496d-a804-7f533ba7a6cbn%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/c3053cb0-d739-496d-a804-7f533ba7a6cbn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfEZ1Ge53nrLAZ7h_tJqrXRTUaBYZg7EV7yi7wzEGwC5Qw%40mail.gmail.com.