eerrors

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UnknownReason is unknown reason for error info.
	UnknownReason = ""
	// SupportPackageIsVersion1 this constant should not be referenced by any other code.
	SupportPackageIsVersion1 = true
)

Variables

View Source
var File_core_eerrors_errors_proto protoreflect.FileDescriptor

Functions

func Register

func Register(egoError *EgoError)

Register 注册错误信息

Types

type EgoError

type EgoError 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 FromError

func FromError(err error) *EgoError

FromError try to convert an error to *Error. It supports wrapped errors.

func New

func New(code int, reason, message string) *EgoError

New returns an error object for the code, message.

func (*EgoError) Descriptor deprecated

func (*EgoError) Descriptor() ([]byte, []int)

Deprecated: Use EgoError.ProtoReflect.Descriptor instead.

func (*EgoError) Error

func (x *EgoError) Error() string

Error Error信息

func (*EgoError) GRPCStatus

func (x *EgoError) GRPCStatus() *status.Status

GRPCStatus returns the Status represented by se.

func (*EgoError) GetCode

func (x *EgoError) GetCode() int32

func (*EgoError) GetMessage

func (x *EgoError) GetMessage() string

func (*EgoError) GetMetadata

func (x *EgoError) GetMetadata() map[string]string

func (*EgoError) GetReason

func (x *EgoError) GetReason() string

func (*EgoError) Is

func (x *EgoError) Is(err error) bool

Is 判断是否为根因错误

func (*EgoError) ProtoMessage

func (*EgoError) ProtoMessage()

func (*EgoError) ProtoReflect

func (x *EgoError) ProtoReflect() protoreflect.Message

func (*EgoError) Reset

func (x *EgoError) Reset()

func (*EgoError) String

func (x *EgoError) String() string

func (*EgoError) ToHTTPStatusCode

func (x *EgoError) ToHTTPStatusCode() int

ToHTTPStatusCode Get equivalent HTTP status code from x.Code

func (*EgoError) WithMessage

func (x *EgoError) WithMessage(msg string) Error

WithMessage set message to current EgoError

func (*EgoError) WithMetadata

func (x *EgoError) WithMetadata(md map[string]string) Error

WithMetadata with an MD formed by the mapping of key, value.

type Error

type Error interface {
	error
	WithMetadata(map[string]string) Error
	WithMessage(string) Error
}

Error 错误接口

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL