eerrors

package
v1.1.19 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 11 Imported by: 3

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 IsCanceled added in v1.1.6

func IsCanceled(err *EgoError) bool

IsCanceled determines if err is an error which indicates a Canceled error.

func IsDeadlineExceeded added in v1.1.6

func IsDeadlineExceeded(err *EgoError) bool

IsDeadlineExceeded determines if err is an error which indicates a DeadlineExceeded error.

func IsNotFound added in v1.1.6

func IsNotFound(err *EgoError) bool

IsNotFound determines if err is an error which indicates a NotFound error.

func Register

func Register(egoError *EgoError)

Register registers error instance.

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 Canceled added in v1.1.6

func Canceled(reason, message string) *EgoError

Canceled new Canceled error that is mapped to context.Canceled.

func DeadlineExceeded added in v1.1.6

func DeadlineExceeded(reason, message string) *EgoError

DeadlineExceeded new DeadlineExceeded error that is mapped to context.DeadlineExceeded.

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 NotFound added in v1.1.6

func NotFound(reason, message string) *EgoError

NotFound new NotFound error that is mapped to context.NotFound.

func (*EgoError) Descriptor deprecated

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

Deprecated: Use EgoError.ProtoReflect.Descriptor instead.

func (*EgoError) Error

func (x *EgoError) Error() string

Error returns error detail message.

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 will be called in errors.Is method to check error type.

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) WithMd added in v1.1.6

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

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

func (*EgoError) WithMessage added in v0.6.10

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

WithMessage set message to current EgoError Deprecated: Will be removed in future versions, use WithMsg instead.

func (*EgoError) WithMetadata

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

WithMetadata with an MD formed by the mapping of key, value. Deprecated: Will be removed in future versions, use WithMd instead.

func (*EgoError) WithMsg added in v1.1.6

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

WithMsg set message to current EgoError

type Error

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

Error defines an grpc error that can be transformed between micro-service caller and micro-service callee.

Jump to

Keyboard shortcuts

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