package apierror
import "github.com/googleapis/gax-go/v2/apierror"
Package apierror implements a wrapper error for parsing error details from API calls. Currently, only errors representing a gRPC status are supported.
Index ¶
- type APIError
- func FromError(err error) (*APIError, bool)
- func (a *APIError) Details() ErrDetails
- func (a *APIError) Domain() string
- func (a *APIError) Error() string
- func (a *APIError) GRPCStatus() *status.Status
- func (a *APIError) Metadata() map[string]string
- func (a *APIError) Reason() string
- func (a *APIError) Unwrap() error
- type ErrDetails
Types ¶
type APIError ¶
type APIError struct {
// contains filtered or unexported fields
}
APIError wraps either a gRPC Status error or a HTTP googleapi.Error. It implements error and Status interfaces.
func FromError ¶
FromError parses a Status error or a googleapi.Error and builds an APIError.
func (*APIError) Details ¶
func (a *APIError) Details() ErrDetails
Details presents the error details of the APIError.
func (*APIError) Domain ¶
Domain returns the domain in an ErrorInfo. If ErrorInfo is nil, it returns an empty string.
func (*APIError) Error ¶
Error returns a readable representation of the APIError.
func (*APIError) GRPCStatus ¶
GRPCStatus extracts the underlying gRPC Status error. This method is necessary to fulfill the interface described in https://pkg.go.dev/google.golang.org/grpc/status#FromError.
func (*APIError) Metadata ¶
Metadata returns the metadata in an ErrorInfo. If ErrorInfo is nil, it returns nil.
func (*APIError) Reason ¶
Reason returns the reason in an ErrorInfo. If ErrorInfo is nil, it returns an empty string.
func (*APIError) Unwrap ¶
Unwrap extracts the original error.
type ErrDetails ¶
type ErrDetails struct { ErrorInfo *errdetails.ErrorInfo BadRequest *errdetails.BadRequest PreconditionFailure *errdetails.PreconditionFailure QuotaFailure *errdetails.QuotaFailure RetryInfo *errdetails.RetryInfo ResourceInfo *errdetails.ResourceInfo RequestInfo *errdetails.RequestInfo DebugInfo *errdetails.DebugInfo Help *errdetails.Help LocalizedMessage *errdetails.LocalizedMessage // Unknown stores unidentifiable error details. Unknown []interface{} }
ErrDetails holds the google/rpc/error_details.proto messages.
func (ErrDetails) String ¶
func (e ErrDetails) String() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
apierror/internal |
- Version
- v2.1.1
- Published
- Sep 16, 2021
- Platform
- darwin/amd64
- Imports
- 7 packages
- Last checked
- 2 hours ago –
Tools for package owners.