Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc(all): fix formatting in error handling godoc #6709

Merged
merged 3 commits into from Sep 21, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions doc.go
Expand Up @@ -182,15 +182,16 @@ For HTTP logging, set the GODEBUG environment variable to "http2debug=1" or "htt
# Inspecting errors

Most of the errors returned by the generated clients are wrapped in an
`apierror.APIError` (https://pkg.go.dev/github.com/googleapis/gax-go/v2/apierror)
and can be further unwrapped into a `grpc.Status` or `googleapi.Error` depending
[github.com/googleapis/gax-go/v2/apierror.APIError] and can be further unwrapped
into a [google.golang.org/grpc/status.Status] or
[google.golang.org/api/googleapi.Error] depending
on the transport used to make the call (gRPC or REST). Converting your errors to
these types can be a useful way to get more information about what went wrong
while debugging.

`apierror.APIError` gives access to specific details in the
error. The transport-specific errors can still be unwrapped using the
`apierror.APIError`.
[github.com/googleapis/gax-go/v2/apierror.APIError] gives access to specific
details in the error. The transport-specific errors can still be unwrapped using
the [github.com/googleapis/gax-go/v2/apierror.APIError].

if err != nil {
var ae *apierror.APIError
Expand All @@ -200,8 +201,8 @@ error. The transport-specific errors can still be unwrapped using the
}
}

If the gRPC transport was used, the `grpc.Status` can still be parsed using the
`status.FromError` function.
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 {
Expand All @@ -212,8 +213,9 @@ If the gRPC transport was used, the `grpc.Status` can still be parsed using the
}
}

If the REST transport was used, the `googleapi.Error` can be parsed in a similar
way.
If the REST transport was used, the [google.golang.org/api/googleapi.Error] can
be parsed in a similar way, allowing access to details such as the HTTP response
code.

if err != nil {
var gerr *googleapi.Error
Expand Down