Documentation ¶
Index ¶
- Constants
- Variables
- func Convert(err error) *status.Status
- func GrpcToHTTPStatusCode(statusCode codes.Code) int
- func IsCanceled(err *GoError) bool
- func IsDeadlineExceeded(err *GoError) bool
- func IsNotFound(err *GoError) bool
- func Register(goError *GoError)
- type Error
- type GoError
- func (*GoError) Descriptor() ([]byte, []int)deprecated
- func (x *GoError) Error() string
- func (x *GoError) GRPCStatus() *status.Status
- func (x *GoError) GetCode() int32
- func (x *GoError) GetMessage() string
- func (x *GoError) GetMetadata() map[string]string
- func (x *GoError) GetReason() string
- func (x *GoError) Is(err error) bool
- func (*GoError) ProtoMessage()
- func (x *GoError) ProtoReflect() protoreflect.Message
- func (x *GoError) Reset()
- func (x *GoError) String() string
- func (x *GoError) ToHTTPStatusCode() int
- func (x *GoError) WithMd(md map[string]string) Error
- func (x *GoError) WithMessage(msg string) Error
- func (x *GoError) WithMetadata(md map[string]string) Error
- func (x *GoError) WithMsg(msg string) Error
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 GrpcToHTTPStatusCode ¶
GrpcToHTTPStatusCode gRPC转HTTP Code example: spbStatus := status.FromContextError(err) httpStatusCode := ecode.GrpcToHTTPStatusCode(spbStatus.Code())
func IsCanceled ¶
IsCanceled determines if err is an error which indicates a Canceled error.
func IsDeadlineExceeded ¶
IsDeadlineExceeded determines if err is an error which indicates a DeadlineExceeded error.
func IsNotFound ¶
IsNotFound determines if err is an error which indicates a NotFound error.
Types ¶
type Error ¶
type Error interface { error WithMetadata(map[string]string) Error WithMd(map[string]string) Error WithMessage(string) Error WithMsg(string) Error }
Error defines an grpc error that can be transformed between micro-service caller and micro-service callee.
type GoError ¶
type GoError 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 DeadlineExceeded ¶
DeadlineExceeded new DeadlineExceeded error that is mapped to context.DeadlineExceeded.
func (*GoError) Descriptor
deprecated
func (*GoError) GRPCStatus ¶
GRPCStatus returns the Status represented by se.
func (*GoError) GetMessage ¶
func (*GoError) GetMetadata ¶
func (*GoError) ProtoMessage ¶
func (*GoError) ProtoMessage()
func (*GoError) ProtoReflect ¶
func (x *GoError) ProtoReflect() protoreflect.Message
func (*GoError) ToHTTPStatusCode ¶
ToHTTPStatusCode Get equivalent HTTP status code from x.Code
func (*GoError) WithMessage ¶
WithMessage set message to current GoError Deprecated: Will be removed in future versions, use WithMsg instead.
func (*GoError) WithMetadata ¶
WithMetadata with an MD formed by the mapping of key, value. Deprecated: Will be removed in future versions, use WithMd instead.