Skip to content

Commit

Permalink
docs: clean up info on gRPC error parsing (#11030)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
codyoss authored Oct 24, 2024
1 parent 5f3d8d7 commit fe32fff
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fe32fff

Please sign in to comment.