Documentation ¶
Index ¶
- Constants
- Variables
- func New(code int, err error) error
- func Transform(err error) int
- type ErrorV2
- func (e *ErrorV2) Code() int
- func (e *ErrorV2) Equal(code int, reason ...string) 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) Reason() string
- func (e *ErrorV2) Unwrap() error
- func (e *ErrorV2) WithCause(cause error) *ErrorV2
- func (e *ErrorV2) WithMetadata(md map[string]string) *ErrorV2
- type Status
- func (*Status) Descriptor() ([]byte, []int)deprecated
- func (x *Status) GetCode() int32
- func (x *Status) GetMessage() string
- func (x *Status) GetMetadata() map[string]string
- func (x *Status) GetReason() string
- func (*Status) ProtoMessage()
- func (x *Status) ProtoReflect() protoreflect.Message
- func (x *Status) Reset()
- func (x *Status) String() string
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_errors_proto protoreflect.FileDescriptor
Functions ¶
Types ¶
type ErrorV2 ¶ added in v2.1.7
type ErrorV2 struct { Status // 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 NewV2WithReason ¶ added in v2.1.7
NewV2WithReason returns an error object for the code, message.
func (*ErrorV2) GRPCStatus ¶ added in v2.1.7
GRPCStatus returns the Status represented by error.
type Status ¶ added in v2.1.7
type Status 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 (*Status) Descriptor
deprecated
added in
v2.1.7
func (*Status) GetMessage ¶ added in v2.1.7
func (*Status) GetMetadata ¶ added in v2.1.7
func (*Status) ProtoMessage ¶ added in v2.1.7
func (*Status) ProtoMessage()
func (*Status) ProtoReflect ¶ added in v2.1.7
func (x *Status) ProtoReflect() protoreflect.Message
Click to show internal directories.
Click to hide internal directories.