eerrors

package
v0.6.13 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: MIT Imports: 13 Imported by: 10 modules, 11 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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_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