errors

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var File_errors_errors_proto protoreflect.FileDescriptor

Functions

func Errorf

func Errorf(code, reason, format string, a ...interface{}) error

Errorf returns an error object for the code, reason, message and error info.

func Reason

func Reason(err error) string

Reason returns the reason for a particular error. It supports wrapped errors.

Types

type Error

type Error struct {
	Code     string            `protobuf:"bytes,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) *Error

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

func New

func New(code, reason, message string) *Error

New returns an error object for the code, reason, message.

func Newf

func Newf(code, reason, format string, a ...interface{}) *Error

Newf New(code, reason, fmt.Sprintf(format, a...))

func (*Error) Descriptor deprecated

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

Deprecated: Use Error.ProtoReflect.Descriptor instead.

func (*Error) Error

func (e *Error) Error() string

func (*Error) GetCode

func (x *Error) GetCode() string

func (*Error) GetMessage

func (x *Error) GetMessage() string

func (*Error) GetMetadata

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

func (*Error) GetReason

func (x *Error) GetReason() string

func (*Error) Is

func (e *Error) Is(err error) bool

Is matches each error in the chain with the target value.

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) ProtoReflect

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

func (*Error) Reset

func (x *Error) Reset()

func (*Error) String

func (x *Error) String() string

func (*Error) WithMetadata

func (e *Error) WithMetadata(md map[string]string) *Error

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

Jump to

Keyboard shortcuts

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