Documentation ¶
Index ¶
- func AbortedErrorf(format string, args ...interface{}) error
- func AlreadyExistsErrorf(format string, args ...interface{}) error
- func CancelledErrorf(format string, args ...interface{}) error
- func DataLossErrorf(format string, args ...interface{}) error
- func DeadlineExceededErrorf(format string, args ...interface{}) error
- func ErrorMessage(err error) stringdeprecated
- func ErrorName(err error) stringdeprecated
- func FailedPreconditionErrorf(format string, args ...interface{}) error
- func FromHeaders(code Code, name string, message string) errordeprecated
- func InternalErrorf(format string, args ...interface{}) error
- func InvalidArgumentErrorf(format string, args ...interface{}) error
- func IsAborted(err error) bool
- func IsAlreadyExists(err error) bool
- func IsCancelled(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 IsOutOfRange(err error) bool
- func IsPermissionDenied(err error) bool
- func IsResourceExhausted(err error) bool
- func IsStatus(err error) bool
- func IsUnauthenticated(err error) bool
- func IsUnavailable(err error) bool
- func IsUnimplemented(err error) bool
- func IsUnknown(err error) bool
- func IsYARPCError(err error) booldeprecated
- func NamedErrorf(name string, format string, args ...interface{}) errordeprecated
- func NotFoundErrorf(format string, args ...interface{}) error
- func OutOfRangeErrorf(format string, args ...interface{}) error
- func PermissionDeniedErrorf(format string, args ...interface{}) error
- func ResourceExhaustedErrorf(format string, args ...interface{}) error
- func UnauthenticatedErrorf(format string, args ...interface{}) error
- func UnavailableErrorf(format string, args ...interface{}) error
- func UnimplementedErrorf(format string, args ...interface{}) error
- func UnknownErrorf(format string, args ...interface{}) error
- type Code
- func ErrorCode(err error) Codedeprecated
- type Fault
- type Status
- func (s *Status) Code() Code
- func (s *Status) Details() []byte
- func (s *Status) Error() string
- func (s *Status) Message() string
- func (s *Status) Name() string
- func (s *Status) Unwrap() error
- func (s *Status) WithDetails(details []byte) *Status
- func (s *Status) WithName(name string) *Statusdeprecated
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbortedErrorf ¶
AbortedErrorf returns a new Status with code CodeAborted by calling Newf(CodeAborted, format, args...).
func AlreadyExistsErrorf ¶
AlreadyExistsErrorf returns a new Status with code CodeAlreadyExists by calling Newf(CodeAlreadyExists, format, args...).
func CancelledErrorf ¶
CancelledErrorf returns a new Status with code CodeCancelled by calling Newf(CodeCancelled, format, args...).
func DataLossErrorf ¶
DataLossErrorf returns a new Status with code CodeDataLoss by calling Newf(CodeDataLoss, format, args...).
func DeadlineExceededErrorf ¶
DeadlineExceededErrorf returns a new Status with code CodeDeadlineExceeded by calling Newf(CodeDeadlineExceeded, format, args...).
func ErrorMessage
deprecated
func FailedPreconditionErrorf ¶
FailedPreconditionErrorf returns a new Status with code CodeFailedPrecondition by calling Newf(CodeFailedPrecondition, format, args...).
func FromHeaders
deprecated
FromHeaders returns a new Status from headers transmitted from the server side.
If the specified code is CodeOK, this will return nil.
The name must only contain lowercase letters from a-z and dashes (-), and cannot start or end in a dash. If the name is something else, an error with code CodeInternal will be returned.
This function should not be used by server implementations, use the individual error constructors instead. This should only be used by transport implementations.
Deprecated: Use Newf and WithName instead.
func InternalErrorf ¶
InternalErrorf returns a new Status with code CodeInternal by calling Newf(CodeInternal, format, args...).
func InvalidArgumentErrorf ¶
InvalidArgumentErrorf returns a new Status with code CodeInvalidArgument by calling Newf(CodeInvalidArgument, format, args...).
func IsAlreadyExists ¶
IsAlreadyExists returns true if FromError(err).Code() == CodeAlreadyExists.
func IsCancelled ¶
IsCancelled returns true if FromError(err).Code() == CodeCancelled.
func IsDataLoss ¶
IsDataLoss returns true if FromError(err).Code() == CodeDataLoss.
func IsDeadlineExceeded ¶
IsDeadlineExceeded returns true if FromError(err).Code() == CodeDeadlineExceeded.
func IsFailedPrecondition ¶
IsFailedPrecondition returns true if FromError(err).Code() == CodeFailedPrecondition.
func IsInternal ¶
IsInternal returns true if FromError(err).Code() == CodeInternal.
func IsInvalidArgument ¶
IsInvalidArgument returns true if FromError(err).Code() == CodeInvalidArgument.
func IsNotFound ¶
IsNotFound returns true if FromError(err).Code() == CodeNotFound.
func IsOutOfRange ¶
IsOutOfRange returns true if FromError(err).Code() == CodeOutOfRange.
func IsPermissionDenied ¶
IsPermissionDenied returns true if FromError(err).Code() == CodePermissionDenied.
func IsResourceExhausted ¶
IsResourceExhausted returns true if FromError(err).Code() == CodeResourceExhausted.
func IsStatus ¶ added in v1.17.0
IsStatus returns whether the provided error is a YARPC error, or has a YARPCError() function to represent the error as a YARPC error. This includes wrapped errors.
This is false if the error is nil.
func IsUnauthenticated ¶
IsUnauthenticated returns true if FromError(err).Code() == CodeUnauthenticated.
func IsUnavailable ¶
IsUnavailable returns true if FromError(err).Code() == CodeUnavailable.
func IsUnimplemented ¶
IsUnimplemented returns true if FromError(err).Code() == CodeUnimplemented.
func IsYARPCError
deprecated
func NamedErrorf
deprecated
NamedErrorf returns a new Status with code CodeUnknown and the given name.
This should be used for user-defined errors.
The name must only contain lowercase letters from a-z and dashes (-), and cannot start or end in a dash. If the name is something else, an error with code CodeInternal will be returned.
Deprecated: Use Newf and WithName instead.
func NotFoundErrorf ¶
NotFoundErrorf returns a new Status with code CodeNotFound by calling Newf(CodeNotFound, format, args...).
func OutOfRangeErrorf ¶
OutOfRangeErrorf returns a new Status with code CodeOutOfRange by calling Newf(CodeOutOfRange, format, args...).
func PermissionDeniedErrorf ¶
PermissionDeniedErrorf returns a new Status with code CodePermissionDenied by calling Newf(CodePermissionDenied, format, args...).
func ResourceExhaustedErrorf ¶
ResourceExhaustedErrorf returns a new Status with code CodeResourceExhausted by calling Newf(CodeResourceExhausted, format, args...).
func UnauthenticatedErrorf ¶
UnauthenticatedErrorf returns a new Status with code CodeUnauthenticated by calling Newf(CodeUnauthenticated, format, args...).
func UnavailableErrorf ¶
UnavailableErrorf returns a new Status with code CodeUnavailable by calling Newf(CodeUnavailable, format, args...).
func UnimplementedErrorf ¶
UnimplementedErrorf returns a new Status with code CodeUnimplemented by calling Newf(CodeUnimplemented, format, args...).
func UnknownErrorf ¶
UnknownErrorf returns a new Status with code CodeUnknown by calling Newf(CodeUnknown, format, args...).
Types ¶
type Code ¶
type Code int
Code represents the type of error for an RPC call.
Sometimes multiple error codes may apply. Services should return the most specific error code that applies. For example, prefer `OutOfRange` over `FailedPrecondition` if both codes apply. Similarly prefer `NotFound` or `AlreadyExists` over `FailedPrecondition`.
These codes are meant to match gRPC status codes. https://godoc.org/google.golang.org/grpc/codes#Code
const ( // CodeOK means no error; returned on success CodeOK Code = 0 // CodeCancelled means the operation was cancelled, typically by the caller. // This is considered as a client error. CodeCancelled Code = 1 // CodeUnknown means an unknown error. Errors raised by APIs // that do not return enough error information // may be converted to this error. // This is considered as a server error. CodeUnknown Code = 2 // CodeInvalidArgument means the client specified an invalid argument. // Note that this differs from `FailedPrecondition`. `InvalidArgument` // indicates arguments that are problematic regardless of the state of // the system (e.g., a malformed file name). // This is considered as a client error. CodeInvalidArgument Code = 3 // CodeDeadlineExceeded means the deadline expired before the operation could // complete. 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. // This is considered as a server error. CodeDeadlineExceeded Code = 4 // CodeNotFound means some requested entity (e.g., file or directory) was not found. // For privacy reasons, this code *may* be returned when the client // does not have the access rights to the entity, though such usage is // discouraged. // This is considered as a client error. CodeNotFound Code = 5 // CodeAlreadyExists means the entity that a client attempted to create // (e.g., file or directory) already exists. // This is considered as a client error. CodeAlreadyExists Code = 6 // CodePermissionDenied means the caller does not have permission to execute // the specified operation. `PermissionDenied` must not be used for rejections // caused by exhausting some resource (use `ResourceExhausted` // instead for those errors). `PermissionDenied` must not be // used if the caller can not be identified (use `Unauthenticated` // instead for those errors). // This is considered as a client error. CodePermissionDenied Code = 7 // CodeResourceExhausted means some resource has been exhausted, perhaps a per-user // quota, or perhaps the entire file system is out of space. // This is considered as a client error. CodeResourceExhausted Code = 8 // CodeFailedPrecondition means the operation was rejected because the system is not // in a state required for the operation's execution. For example, the directory // to be deleted is non-empty, an rmdir operation is applied to // a non-directory, etc. // // Service implementors can use the following guidelines to decide // 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 // the files are deleted from the directory. // This is considered as a client error. CodeFailedPrecondition Code = 9 // CodeAborted means the operation was aborted, typically due to a concurrency issue // such as a sequencer check failure or transaction abort. // // See the guidelines above for deciding between `FailedPrecondition`, // `Aborted`, and `Unavailable`. // This is considered as a client error. CodeAborted Code = 10 // CodeOutOfRange means the 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. // This is considered as a client error. CodeOutOfRange Code = 11 // CodeUnimplemented means the operation is not implemented or is not // supported/enabled in this service. // This is considered as a client error. CodeUnimplemented Code = 12 // CodeInternal means an internal error. This means that some invariants expected // by the underlying system have been broken. This error code is reserved // for serious errors. // This is considered as a server error. CodeInternal Code = 13 // transient condition, which can be corrected by retrying with a backoff. // // See the guidelines above for deciding between `FailedPrecondition`, // `Aborted`, and `Unavailable`. // This is considered as a server error. CodeUnavailable Code = 14 // CodeDataLoss means unrecoverable data loss or corruption. // This is considered as a server error. CodeDataLoss Code = 15 // CodeUnauthenticated means the request does not have valid authentication // credentials for the operation. // This is considered as a client error. CodeUnauthenticated Code = 16 )
func (Code) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Code) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Code) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Code) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Fault ¶ added in v1.73.0
type Fault int
Fault is a type of error.
func GetFaultTypeFromCode ¶ added in v1.69.1
GetFaultTypeFromCode determines whether the status code is a client, server or indeterminate fault based on a YARPC Code.
func GetFaultTypeFromError ¶ added in v1.69.1
GetFaultTypeFromError determines whether the error is a client, server or indeterminate fault based on a YARPC Code.
type Status ¶ added in v1.17.0
type Status struct {
// contains filtered or unexported fields
}
Status represents a YARPC error.
func FromError ¶ added in v1.17.0
FromError returns the Status for the provided error.
If the error:
- is nil, return nil
- is a 'Status', return the 'Status'
- has a 'YARPCError() *Status' method, returns the 'Status'
Otherwise, return a wrapped error with code 'CodeUnknown'.
func Newf ¶ added in v1.17.0
Newf returns a new Status.
The Code should never be CodeOK, if it is, this will return nil.
func (*Status) Name ¶ added in v1.17.0
Name returns the name of the error for this Status.
This is an empty string for all built-in YARPC errors. It may be customized by using WithName.
func (*Status) Unwrap ¶ added in v1.45.0
Unwrap supports errors.Unwrap.
See "errors" package documentation for details.
func (*Status) WithDetails ¶ added in v1.39.0
WithDetails returns a new status with the given details bytes.