Documentation ¶
Index ¶
- Constants
- Variables
- func Aborted(err *Error) error
- func AlreadyExists(err *Error) error
- func BadRequest(err *Error) error
- func Cancelled(err *Error) error
- func Code(err error) int32
- func Conflict(err *Error) error
- func Convert(err error) *status.Status
- func DataLoss(err *Error) error
- func DeadlineExceeded(err *Error) error
- func Err2GrpcCode(err error) codes.Code
- func FailedPrecondition(err *Error) error
- func Forbidden(err *Error) error
- func GrpcToHTTPStatusCode(statusCode codes.Code) int
- func Http2GrpcCode(code int32) codes.Code
- func Internal(err *Error) error
- func InternalServerError(err *Error) error
- func InvalidArgument(err *Error) error
- func IsAborted(err error) bool
- func IsAlreadyExists(err error) bool
- func IsBisErr(err error) bool
- func IsCancelled(err error) bool
- func IsDataLoss(err error) bool
- func IsDeadlineExceeded(err error) bool
- func IsFailedPrecondition(err error) bool
- func IsGrpcAcceptable(err error) bool
- func IsInternal(err error) bool
- func IsInvalidArgument(err error) bool
- func IsMemoryErr(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(err *Error) error
- func OutOfRange(err *Error) error
- func PermissionDenied(err *Error) error
- func ResourceExhausted(err *Error) error
- func Timeout(err *Error) error
- func Unauthorized(err *Error) error
- func Unavailable(err *Error) error
- func Unimplemented(err *Error) error
- func Unknown(err *Error) error
- type Error
- func (x *Error) AppendMetadata(m map[string]string) *Error
- func (x *Error) As(target interface{}) bool
- func (*Error) Descriptor() ([]byte, []int)deprecated
- func (x *Error) Error() string
- func (x *Error) GRPCStatus() *status.Status
- func (x *Error) GetCode() int32
- func (x *Error) GetMessage() string
- func (x *Error) GetMetadata() map[string]string
- func (x *Error) GetReason() string
- func (x *Error) HTTPStatus() int
- func (x *Error) Is(err error) bool
- func (*Error) ProtoMessage()
- func (x *Error) ProtoReflect() protoreflect.Message
- func (x *Error) Reset()
- func (x *Error) String() string
- func (x *Error) WithMetadata(m map[string]string) *Error
Constants ¶
const MaxCode = 1000
MaxCode [0,1000]为系统错误, 业务错误code都大于1000
Variables ¶
var (
// optional int32 code = 100000;
E_Code = &file_errors_errors_proto_extTypes[0]
)
Extension fields to descriptorpb.EnumValueOptions.
var File_errors_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 Srv Closed Request
func DataLoss ¶
DataLoss Unrecoverable data loss or corruption. HTTP Mapping: 500 Internal Grpc Error
func DeadlineExceeded ¶
DeadlineExceeded The deadline expired before the operation could complete. HTTP Mapping: 504 Gateway Timeout
func Err2GrpcCode ¶
Err2GrpcCode converts a standard Go error into its canonical code. Note that this is only used to translate the error returned by the server applications.
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 GrpcToHTTPStatusCode ¶ added in v0.1.16
GrpcToHTTPStatusCode gRPC转HTTP Code example:
spbStatus := status.FromContextError(err) httpStatusCode := ecode.GrpcToHTTPStatusCode(spbStatus.Code())
func Http2GrpcCode ¶
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 Grpc Error
func InternalServerError ¶
InternalServerError generates a 500 error.
func InvalidArgument ¶
InvalidArgument The client specified an invalid argument. HTTP Mapping: 400 Bad Request
func IsAborted ¶
IsAborted determines if err is an error which indicates an aborted error. It supports wrapped errors.
func IsAlreadyExists ¶
IsAlreadyExists determines if err is an error which indicates a already exsits error. It supports wrapped errors.
func IsCancelled ¶
IsCancelled determines if err is an error which indicates a cancelled error. It supports wrapped errors.
func IsDataLoss ¶
IsDataLoss determines if err is an error which indicates a data loss error. It supports wrapped errors.
func IsDeadlineExceeded ¶
IsDeadlineExceeded determines if err is an error which indicates a deadline exceeded error. It supports wrapped errors.
func IsFailedPrecondition ¶
IsFailedPrecondition determines if err is an error which indicates a failed precondition error. It supports wrapped errors.
func IsGrpcAcceptable ¶
func IsInternal ¶
IsInternal determines if err is an error which indicates an internal server error. It supports wrapped errors.
func IsInvalidArgument ¶
IsInvalidArgument determines if err is an error which indicates an invalid argument error. It supports wrapped errors.
func IsMemoryErr ¶
func IsNotFound ¶
IsNotFound determines if err is an error which indicates a not found error. It supports wrapped errors.
func IsOutOfRange ¶
IsOutOfRange determines if err is an error which indicates a out of range error. It supports wrapped errors.
func IsPermissionDenied ¶
IsPermissionDenied determines if err is an error which indicates a permission denied error. It supports wrapped errors.
func IsResourceExhausted ¶
IsResourceExhausted determines if err is an error which indicates a resource exhausted error. It supports wrapped errors.
func IsUnauthorized ¶
IsUnauthorized determines if err is an error which indicates a unauthorized error. It supports wrapped errors.
func IsUnavailable ¶
IsUnavailable determines if err is an error which indicates a unavailable error. It supports wrapped errors.
func IsUnimplemented ¶
IsUnimplemented determines if err is an error which indicates a unimplemented error. It supports wrapped errors.
func IsUnknown ¶
IsUnknown determines if err is an error which indicates a unknown error. It supports wrapped errors.
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 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 Error ¶
type Error struct { Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` Reason string `protobuf:"bytes,2,opt,name=reason,proto3" json:"reason,omitempty"` Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` Metadata map[string]string `` /* 157-byte string literal not displayed */ // contains filtered or unexported fields }
func (*Error) AppendMetadata ¶ added in v0.2.6
func (*Error) Descriptor
deprecated
func (*Error) GRPCStatus ¶ added in v0.1.16
GRPCStatus 实现grpc status的GRPCStatus接口
func (*Error) GetMessage ¶ added in v0.1.16
func (*Error) GetMetadata ¶ added in v0.1.16
func (*Error) HTTPStatus ¶
HTTPStatus returns the Status represented by se.
func (*Error) ProtoMessage ¶
func (*Error) ProtoMessage()
func (*Error) ProtoReflect ¶
func (x *Error) ProtoReflect() protoreflect.Message