From fe32fff57ee57b3509e250bdfff888cc3662f6e8 Mon Sep 17 00:00:00 2001 From: Cody Oss <6331106+codyoss@users.noreply.github.com> Date: Thu, 24 Oct 2024 15:52:23 -0500 Subject: [PATCH] docs: clean up info on gRPC error parsing (#11030) Show users how to get the gRPC status from our error type. We should push users to handle error constantly where possible. Internal Bug: 372880394 --- doc.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/doc.go b/doc.go index 932e114f70ae..a42152109b0e 100644 --- a/doc.go +++ b/doc.go @@ -247,19 +247,11 @@ errors can still be unwrapped using the APIError. log.Println(ae.Reason()) log.Println(ae.Details().Help.GetLinks()) } - } - -If the gRPC transport was used, the [google.golang.org/grpc/status.Status] can -still be parsed using the [google.golang.org/grpc/status.FromError] function. - - if err != nil { - if s, ok := status.FromError(err); ok { - log.Println(s.Message()) - for _, d := range s.Proto().Details { - log.Println(d) - } + // If a gRPC transport was used you can extract the + // google.golang.org/grpc/status.Status from the error + s := ae.GRPCStatus() + log.Println(s.Code()) } - } # Client Stability