errx

package
v0.0.0-...-0aedd24 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_error_proto protoreflect.FileDescriptor

Functions

func GetErrxField

func GetErrxField[T any](err any, key DetailKey) (result T)

func Map2Pb

func Map2Pb(val any) (m map[string]*Value)

func New

func New(msg string, sets ...func(map[DetailKey]any)) error

func NewFromStatus

func NewFromStatus(s *status.Status) error

NewFromStatus new an error from status.Status

func NewWithSkip

func NewWithSkip(msg string, skip int, sets ...func(map[DetailKey]any)) error

func PbList2SliceAny

func PbList2SliceAny(pbList *List) (s []any)

func PbMap2MapStrAny

func PbMap2MapStrAny(pbMap *Map) (m map[string]any)

func PbValue2Any

func PbValue2Any(pbValue *Value) (v any)

func PrintGrpcStatusErrorDetail

func PrintGrpcStatusErrorDetail(err error)

PrintGrpcStatusErrorDetail 打印err的详细信息

func WithCode

func WithCode(code int) func(map[DetailKey]any)

func Wrap

func Wrap(err error, msg string, sets ...func(map[DetailKey]any)) error

func WrapWithSkip

func WrapWithSkip(err error, message string, skip int, sets ...func(map[DetailKey]any)) error

Types

type DetailKey

type DetailKey string
const (
	Msg      DetailKey = "msg"
	Err      DetailKey = "err"
	File     DetailKey = "file"
	Line     DetailKey = "line"
	ErrStack DetailKey = "errStack"
	Code     DetailKey = "code"
	Detail   DetailKey = "detail"
)

func (DetailKey) IsReserved

func (d DetailKey) IsReserved() bool

type Errx

type Errx map[DetailKey]any

func (Errx) ErrStack

func (e Errx) ErrStack() string

func (Errx) Error

func (e Errx) Error() string

func (Errx) Format

func (e Errx) Format(s fmt.State, c rune)

func (Errx) GRPCStatus

func (e Errx) GRPCStatus() *status.Status

func (Errx) Get

func (e Errx) Get(field DetailKey) (value any, ok bool)

func (Errx) Set

func (e Errx) Set(fields Fields)

type Fields

type Fields map[DetailKey]any

type List

type List struct {
	List []*Value `protobuf:"bytes,1,rep,name=List,proto3" json:"List,omitempty"`
	// contains filtered or unexported fields
}

func (*List) Descriptor deprecated

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

Deprecated: Use List.ProtoReflect.Descriptor instead.

func (*List) GetList

func (x *List) GetList() []*Value

func (*List) ProtoMessage

func (*List) ProtoMessage()

func (*List) ProtoReflect

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

func (*List) Reset

func (x *List) Reset()

func (*List) String

func (x *List) String() string

type Map

type Map struct {
	Fields map[string]*Value `` /* 153-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*Map) Descriptor deprecated

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

Deprecated: Use Map.ProtoReflect.Descriptor instead.

func (*Map) GetFields

func (x *Map) GetFields() map[string]*Value

func (*Map) ProtoMessage

func (*Map) ProtoMessage()

func (*Map) ProtoReflect

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

func (*Map) Reset

func (x *Map) Reset()

func (*Map) String

func (x *Map) String() string

type Value

type Value struct {

	// Types that are assignable to Kind:
	//
	//	*Value_Int32Val
	//	*Value_Int64Val
	//	*Value_StrVal
	//	*Value_MapVal
	//	*Value_ListVal
	Kind isValue_Kind `protobuf_oneof:"Kind"`
	// contains filtered or unexported fields
}

func Any2PbValue

func Any2PbValue(val any) (value *Value)

func (*Value) Descriptor deprecated

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

Deprecated: Use Value.ProtoReflect.Descriptor instead.

func (*Value) GetInt32Val

func (x *Value) GetInt32Val() int32

func (*Value) GetInt64Val

func (x *Value) GetInt64Val() int64

func (*Value) GetKind

func (m *Value) GetKind() isValue_Kind

func (*Value) GetListVal

func (x *Value) GetListVal() *List

func (*Value) GetMapVal

func (x *Value) GetMapVal() *Map

func (*Value) GetStrVal

func (x *Value) GetStrVal() string

func (*Value) ProtoMessage

func (*Value) ProtoMessage()

func (*Value) ProtoReflect

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

func (*Value) Reset

func (x *Value) Reset()

func (*Value) String

func (x *Value) String() string

type Value_Int32Val

type Value_Int32Val struct {
	Int32Val int32 `protobuf:"varint,1,opt,name=Int32Val,proto3,oneof"`
}

type Value_Int64Val

type Value_Int64Val struct {
	Int64Val int64 `protobuf:"varint,2,opt,name=Int64Val,proto3,oneof"`
}

type Value_ListVal

type Value_ListVal struct {
	ListVal *List `protobuf:"bytes,5,opt,name=ListVal,proto3,oneof"`
}

type Value_MapVal

type Value_MapVal struct {
	MapVal *Map `protobuf:"bytes,4,opt,name=MapVal,proto3,oneof"`
}

type Value_StrVal

type Value_StrVal struct {
	StrVal string `protobuf:"bytes,3,opt,name=StrVal,proto3,oneof"`
}

Jump to

Keyboard shortcuts

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