eerrors

package
Version: v0.6.16 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: MIT Imports: 13 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 PrintEgoErrLog added in v0.6.12

func PrintEgoErrLog(msg string, err error)

PrintEgoErrLog ...

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 added in v0.6.10

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 added in v0.6.12

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 added in v0.6.11

func (x *EgoError) ToHTTPStatusCode() int

ToHTTPStatusCode Get equivalent HTTP status code from x.Code

func (*EgoError) WithMessage added in v0.6.10

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