Documentation
¶
Overview ¶
copy from https://github.com/go-kratos/kratos/tree/v2/errors
copy from https://github.com/go-kratos/kratos/tree/v2/errors
Index ¶
- Constants
- Variables
- func Aborted(reason, format string, a ...interface{}) error
- func AlreadyExists(reason, format string, a ...interface{}) error
- func Cancelled(reason, format string, a ...interface{}) error
- func DataLoss(reason, format string, a ...interface{}) error
- func DeadlineExceeded(reason, format string, a ...interface{}) error
- func Error(code int32, message string, details ...proto.Message) error
- func Errorf(code int32, format string, a ...interface{}) error
- func FailedPrecondition(reason, format string, a ...interface{}) error
- func Internal(reason, format string, a ...interface{}) error
- func InvalidArgument(reason, format string, a ...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 IsUnauthorized(err error) bool
- func IsUnavailable(err error) bool
- func IsUnimplemented(err error) bool
- func IsUnknown(err error) bool
- func NotFound(reason, format string, a ...interface{}) error
- func OutOfRange(reason, format string, a ...interface{}) error
- func PermissionDenied(reason, format string, a ...interface{}) error
- func ResourceExhausted(reason, format string, a ...interface{}) error
- func Unauthorized(reason, format string, a ...interface{}) error
- func Unavailable(reason, format string, a ...interface{}) error
- func Unimplemented(reason, format string, a ...interface{}) error
- func Unknown(reason, format string, a ...interface{}) error
- type ErrorItem
- type StatusError
Constants ¶
const ( // UnknownReason is unknown reason for error info. UnknownReason = "" // SupportPackageIsVersion1 this constant should not be referenced by any other code. SupportPackageIsVersion1 = true )
Variables ¶
var File_errors_proto protoreflect.FileDescriptor
Functions ¶
func Aborted ¶
Aborted The operation was aborted, typically due to a concurrency issue such as a sequencer check failure or transaction abort. HTTP Mapping: 409 Conflict
func AlreadyExists ¶
AlreadyExists The entity that a client attempted to create (e.g., file or directory) already exists. HTTP Mapping: 409 Conflict
func Cancelled ¶
Cancelled The operation was cancelled, typically by the caller. HTTP Mapping: 499 Client Closed Request
func DataLoss ¶
DataLoss Unrecoverable data loss or corruption. HTTP Mapping: 500 Internal Server Error
func DeadlineExceeded ¶
DeadlineExceeded The deadline expired before the operation could complete. HTTP Mapping: 504 Gateway Timeout
func FailedPrecondition ¶
FailedPrecondition The operation was rejected because the system is not in a state required for the operation's execution. HTTP Mapping: 400 Bad Request
func Internal ¶
Internal This means that some invariants expected by the underlying system have been broken. This error code is reserved for serious errors.
HTTP Mapping: 500 Internal Server Error
func InvalidArgument ¶
InvalidArgument The client specified an invalid argument. HTTP Mapping: 400 Bad Request
func IsAlreadyExists ¶
func IsCancelled ¶
func IsDataLoss ¶
func IsDeadlineExceeded ¶
func IsFailedPrecondition ¶
func IsInternal ¶
func IsInvalidArgument ¶
func IsNotFound ¶
func IsOutOfRange ¶
func IsPermissionDenied ¶
func IsResourceExhausted ¶
func IsUnauthorized ¶
func IsUnavailable ¶
func IsUnimplemented ¶
func NotFound ¶
NotFound Some requested entity (e.g., file or directory) was not found. HTTP Mapping: 404 Not Found
func OutOfRange ¶
OutOfRange The operation was attempted past the valid range. E.g., seeking or reading past end-of-file. HTTP Mapping: 400 Bad Request
func PermissionDenied ¶
PermissionDenied The caller does not have permission to execute the specified operation. HTTP Mapping: 403 Forbidden
func ResourceExhausted ¶
ResourceExhausted Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. HTTP Mapping: 429 Too Many Requests
func Unauthorized ¶
Unauthorized The request does not have valid authentication credentials for the operation. HTTP Mapping: 401 Unauthorized
func Unavailable ¶
Unavailable The service is currently unavailable. HTTP Mapping: 503 Service Unavailable
func Unimplemented ¶
Unimplemented The operation is not implemented or is not supported/enabled in this service. HTTP Mapping: 501 Not Implemented
Types ¶
type ErrorItem ¶
type ErrorItem struct { // Reason is the typed error code. For example: "some_example". Reason string `protobuf:"bytes,1,opt,name=reason,proto3" json:"reason,omitempty"` // Message is the human-readable description of the error. Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` // contains filtered or unexported fields }
ErrorItem is a detailed error code & message from the API frontend.
func (*ErrorItem) Descriptor
deprecated
func (*ErrorItem) GetMessage ¶
func (*ErrorItem) ProtoMessage ¶
func (*ErrorItem) ProtoMessage()
func (*ErrorItem) ProtoReflect ¶
func (x *ErrorItem) ProtoReflect() protoreflect.Message
type StatusError ¶
type StatusError struct { // Code is the gRPC response status code and will always be populated. Code int32 `json:"code"` // Message is the server response message and is only populated when // explicitly referenced by the JSON server response. Message string `json:"message"` // Details provide more context to an error. Details []proto.Message `json:"details"` }
StatusError contains an error response from the server.
func (*StatusError) Error ¶
func (e *StatusError) Error() string
func (*StatusError) Is ¶
func (e *StatusError) Is(target error) bool
Is matches each error in the chain with the target value.
func (*StatusError) WithDetails ¶
func (e *StatusError) WithDetails(details ...proto.Message)
WithDetails provided details messages appended to the errors.