Documentation ¶
Overview ¶
Package status provide wrapper of package status, codes of grpc-go and some utilities for working with status, errors.
Index ¶
- func Aborted(fmt string, args ...interface{}) error
- func AlreadyExists(fmt string, args ...interface{}) error
- func Canceled(fmt string, args ...interface{}) error
- func DataLoss(fmt string, args ...interface{}) error
- func DeadlineExceeded(fmt string, args ...interface{}) error
- func Error(code Code, fmt string, args ...interface{}) error
- func FailedPrecondition(fmt string, args ...interface{}) error
- func HTTPStatusFromCode(code Code) int
- func Internal(fmt string, args ...interface{}) error
- func InvalidArgument(fmt string, args ...interface{}) error
- func Is(err error, code Code) bool
- func IsAborted(err error) bool
- func IsAlreadyExists(err error) bool
- func IsCanceled(err error) bool
- func IsDataLoss(err error) bool
- func IsDeadlineExceeded(err error) bool
- func IsFailedPrecondition(err error) bool
- func IsInternal(err error) bool
- func IsInvalidArgument(err error) bool
- func IsNotFound(err error) bool
- func IsOK(err error) bool
- func IsOutOfRange(err error) bool
- func IsPermissionDenied(err error) bool
- func IsResourceExhausted(err error) bool
- func IsUnauthenticated(err error) bool
- func IsUnavailable(err error) bool
- func IsUnimplemented(err error) bool
- func IsUnknown(err error) bool
- func JSON(v interface{}) []byte
- func NotFound(fmt string, args ...interface{}) error
- func OutOfRange(fmt string, args ...interface{}) error
- func PermissionDenied(fmt string, args ...interface{}) error
- func ResourceExhausted(fmt string, args ...interface{}) error
- func Unauthenticated(fmt string, args ...interface{}) error
- func Unavailable(fmt string, args ...interface{}) error
- func Unimplemented(fmt string, args ...interface{}) error
- func Unknown(fmt string, args ...interface{}) error
- type Code
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Aborted ¶
Aborted indicates the operation was aborted, typically due to a concurrency issue like sequencer check failures, transaction aborts, etc.
func AlreadyExists ¶
AlreadyExists means an attempt to create an entity failed because one already exists.
func DeadlineExceeded ¶
DeadlineExceeded means operation expired before completion. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long enough for the deadline to expire.
func FailedPrecondition ¶
FailedPrecondition indicates operation was rejected because the system is not in a state required for the operation's execution. For example, directory to be deleted may be non-empty, an rmdir operation is applied to a non-directory, etc.
A litmus test that may help a service implementor in deciding between FailedPrecondition, Aborted, and Unavailable:
(a) Use Unavailable if the client can retry just the failing call. (b) Use Aborted if the client should retry at a higher-level (e.g., restarting a read-modify-write sequence). (c) Use FailedPrecondition if the client should not retry until the system state has been explicitly fixed. E.g., if an "rmdir" fails because the directory is non-empty, FailedPrecondition should be returned since the client should not retry unless they have first fixed up the directory by deleting files from it. (d) Use FailedPrecondition if the client performs conditional REST Get/Update/Delete on a resource and the resource on the server does not match the condition. E.g., conflicting read-modify-write on the same resource.
func HTTPStatusFromCode ¶
HTTPStatusFromCode converts a gRPC error code into the corresponding HTTP response status. See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
func Internal ¶
Internal errors. Means some invariants expected by underlying system has been broken. If you see one of these errors, something is very broken.
func InvalidArgument ¶
InvalidArgument indicates client specified an invalid argument. Note that this differs from FailedPrecondition. It indicates arguments that are problematic regardless of the state of the system (e.g., a malformed file name).
func IsAlreadyExists ¶
IsAlreadyExists check whether the given error is an AlreadyExists error.
func IsCanceled ¶
IsCanceled check whether the error is a Canceled error.
func IsDataLoss ¶
IsDataLoss check whether the given error is a DataLoss error.
func IsDeadlineExceeded ¶
IsDeadlineExceeded check whether the given error is a DeadlineExceeded error.
func IsFailedPrecondition ¶
IsFailedPrecondition check whether the given error is a FailedPrecondition error.
func IsInternal ¶
IsInternal check whether the given error is an Internal error.
func IsInvalidArgument ¶
IsInvalidArgument check whether the given error is an InvalidArgument.
func IsNotFound ¶
IsNotFound check whether the given error is a NotFound error.
func IsOutOfRange ¶
IsOutOfRange check whether the given error is an OutOfRange error.
func IsPermissionDenied ¶
IsPermissionDenied check whether the given error is a PermissionDenied error.
func IsResourceExhausted ¶
IsResourceExhausted check whether the given error is a ResourceExhausted error.
func IsUnauthenticated ¶
IsUnauthenticated check whether the given error is an Unauthenticated error.
func IsUnavailable ¶
IsUnavailable check whether the given error is an Unavailable error.
func IsUnimplemented ¶
IsUnimplemented check whether the given error is an Unimplemented error.
func OutOfRange ¶
OutOfRange means operation was attempted past the valid range. E.g., seeking or reading past end of file.
Unlike InvalidArgument, this error indicates a problem that may be fixed if the system state changes. For example, a 32-bit file system will generate InvalidArgument if asked to read at an offset that is not in the range [0,2^32-1], but it will generate OutOfRange if asked to read from an offset past the current file size.
There is a fair bit of overlap between FailedPrecondition and OutOfRange. We recommend using OutOfRange (the more specific error) when it applies so that callers who are iterating through a space can easily look for an OutOfRange error to detect when they are done.
func PermissionDenied ¶
PermissionDenied indicates the caller does not have permission to execute the specified operation. It must not be used for rejections caused by exhausting some resource (use ResourceExhausted instead for those errors). It must not be used if the caller cannot be identified (use Unauthenticated instead for those errors).
func ResourceExhausted ¶
ResourceExhausted indicates some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space.
This error code will be generated by the gRPC framework in out-of-memory and server overload situations, or when a message is larger than the configured maximum size.
func Unauthenticated ¶
Unauthenticated indicates the request does not have valid authentication credentials for the operation.
func Unavailable ¶
Unavailable indicates the service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff. Note that it is not always safe to retry non-idempotent operations.
func Unimplemented ¶
Unimplemented indicates operation is not implemented or not supported/enabled in this service.
This error code will be generated by the gRPC framework. Most commonly, you will see this error code when a method implementation is missing on the server. It can also be generated for unknown compression algorithms or a disagreement as to whether an RPC should be streaming.
func Unknown ¶
Unknown error. An example of where this error may be returned is if a Status value received from another address space belongs to an error-space that is not known in this address space. Also errors raised by APIs that do not return enough error information may be converted to this error.
Types ¶
type Status ¶
Status is an alias of grpc status.Status.
func Convert ¶
Convert is a convenience function which removes the need to handle the boolean return value from FromError.