Documentation ¶
Overview ¶
Package grpc attaches GRPC codes to the standard error codes. It also provides helpers for integrating with GRPC.
Note that not all GRPC codes are mapped right now: you are welcome to contribute more. Available mappings are documented here: https://cloud.google.com/apis/design/errors
The init functiom performs the mapping and is reproduced here:
SetCode(errcode.InternalCode, codes.Internal) SetCode(errcode.InvalidInputCode, codes.InvalidArgument) SetCode(errcode.NotFoundCode, codes.NotFound) SetCode(errcode.StateCode, codes.FailedPrecondition) SetCode(errcode.ForbiddenCode, codes.PermissionDenied) SetCode(errcode.NotAuthenticatedCode, codes.Unauthenticated) SetCode(errcode.AlreadyExistsCode, codes.AlreadyExists) SetCode(errcode.OutOfRangeCode, codes.OutOfRange) SetCode(errcode.UnimplementedCode, codes.Unimplemented)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCode ¶
GetCode retrieves the GRPC code for a code or its first ancestor with a GRPC code. If none are specified, it defaults to Unkown (Code 2). The return of this is a GRPC codes package Code, not an errcode.Code
Types ¶
type ErrorCodeStatus ¶
type ErrorCodeStatus interface { errcode.ErrorCode StatusGRPC }
ErrorCodeStatus is both an ErrorCode and a GRPC Status
func WrapAsGRPC ¶
func WrapAsGRPC(code errcode.ErrorCode) ErrorCodeStatus
WrapAsGRPC constructs a value that responds as both an ErrorCode and as a GRPC status
type StatusGRPC ¶
StatusGRPC is the interface to a GRPC status code