You cant to use status.Code(err)
<https://pkg.go.dev/google.golang.org/grpc/status#Code>, which gives you
the gRPC status code.


On Tue, May 18, 2021 at 3:08 PM cpu...@gmail.com <cpui...@gmail.com> wrote:

>
> Thank you for the pointer. After looking at the API, I'm still confused
> how to use it. I can status.Convert(err) to get a status object but
> couldn't really figure how how to use that to extract the actual underlying
> base error?
> On Saturday, May 15, 2021 at 2:12:28 PM UTC+2 kortschak wrote:
>
>> On Sat, 2021-05-15 at 04:47 -0700, cpu...@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?
>> >
>>
>> There is the status package which provides tools for examining the gRPC
>> errors, https://pkg.go.dev/google.golang.org/grpc/status.
>>
>>
>> --
> 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/8ecd4024-a846-4657-8e61-15c16289ccd2n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/8ecd4024-a846-4657-8e61-15c16289ccd2n%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/CAEkBMfERsv28%2BJV-EVYqhZraHbyYmPftQV6V0i55zVaK1R13HQ%40mail.gmail.com.

Reply via email to