Skip to content

Commit fe32fff

Browse files
authored
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
1 parent 5f3d8d7 commit fe32fff

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

doc.go

+4-12
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,11 @@ errors can still be unwrapped using the APIError.
247247
log.Println(ae.Reason())
248248
log.Println(ae.Details().Help.GetLinks())
249249
}
250-
}
251-
252-
If the gRPC transport was used, the [google.golang.org/grpc/status.Status] can
253-
still be parsed using the [google.golang.org/grpc/status.FromError] function.
254-
255-
if err != nil {
256-
if s, ok := status.FromError(err); ok {
257-
log.Println(s.Message())
258-
for _, d := range s.Proto().Details {
259-
log.Println(d)
260-
}
250+
// If a gRPC transport was used you can extract the
251+
// google.golang.org/grpc/status.Status from the error
252+
s := ae.GRPCStatus()
253+
log.Println(s.Code())
261254
}
262-
}
263255
264256
# Client Stability
265257

0 commit comments

Comments
 (0)