Documentation ¶
Index ¶
- Constants
- Variables
- func New(code int, err error) error
- func Transform(err error) int
- type ErrorStatus
- func (*ErrorStatus) Descriptor() ([]byte, []int)deprecated
- func (x *ErrorStatus) GetCode() int64
- func (x *ErrorStatus) GetMetadata() map[string]string
- func (x *ErrorStatus) GetMsg() string
- func (*ErrorStatus) ProtoMessage()
- func (x *ErrorStatus) ProtoReflect() protoreflect.Message
- func (x *ErrorStatus) Reset()
- func (x *ErrorStatus) String() string
- type ErrorV2
- func (e *ErrorV2) Code() int
- func (e *ErrorV2) Equal(code int) bool
- func (e *ErrorV2) Error() string
- func (e *ErrorV2) GRPCStatus() *status.Status
- func (e *ErrorV2) Is(err error) bool
- func (e *ErrorV2) Message() string
- func (e *ErrorV2) Unwrap() error
- func (e *ErrorV2) WithCause(cause error) *ErrorV2
- func (e *ErrorV2) WithMetadata(md map[string]string) *ErrorV2
Constants ¶
View Source
const ( // UnknownCode is unknown code for error info. UnknownCode = http.StatusInternalServerError SystemErrorCode = -1 // UnknownReason is unknown reason for error info. UnknownReason = "" // ClientClosed is non-standard http status code, // which defined by nginx. // https://httpstatus.in/499/ ClientClosed = 499 )
Variables ¶
View Source
var ( // base error Success = NewV2(1, "success") SystemError = NewV2(SystemErrorCode, "system error") )
View Source
var DefaultConverter = statusConverter{}
DefaultConverter default converter.
View Source
var File_api_ecode_errors_v2_proto protoreflect.FileDescriptor
Functions ¶
Types ¶
type ErrorStatus ¶ added in v2.1.20
type ErrorStatus struct { Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` Metadata map[string]string `` /* 157-byte string literal not displayed */ // contains filtered or unexported fields }
func (*ErrorStatus) Descriptor
deprecated
added in
v2.1.20
func (*ErrorStatus) Descriptor() ([]byte, []int)
Deprecated: Use ErrorStatus.ProtoReflect.Descriptor instead.
func (*ErrorStatus) GetCode ¶ added in v2.1.20
func (x *ErrorStatus) GetCode() int64
func (*ErrorStatus) GetMetadata ¶ added in v2.1.20
func (x *ErrorStatus) GetMetadata() map[string]string
func (*ErrorStatus) GetMsg ¶ added in v2.1.20
func (x *ErrorStatus) GetMsg() string
func (*ErrorStatus) ProtoMessage ¶ added in v2.1.20
func (*ErrorStatus) ProtoMessage()
func (*ErrorStatus) ProtoReflect ¶ added in v2.1.20
func (x *ErrorStatus) ProtoReflect() protoreflect.Message
func (*ErrorStatus) Reset ¶ added in v2.1.20
func (x *ErrorStatus) Reset()
func (*ErrorStatus) String ¶ added in v2.1.20
func (x *ErrorStatus) String() string
type ErrorV2 ¶ added in v2.1.7
type ErrorV2 struct { ErrorStatus // contains filtered or unexported fields }
ErrorV2 struct
func FromError ¶ added in v2.1.7
FromError try to convert an error to *ErrorV2. It supports wrapped errors.
func (*ErrorV2) GRPCStatus ¶ added in v2.1.7
GRPCStatus returns the Status represented by error.
Click to show internal directories.
Click to hide internal directories.