errcode

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 4 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrHandle added in v0.0.28

func ErrHandle(err any) error

func RegisterErrCode

func RegisterErrCode(code ErrCode, msg string)

不是并发安全的,在初始化的时候做

Types

type ErrCode

type ErrCode uint32
const (
	// SysErr ErrCode = -1
	Success         ErrCode = 0
	Canceled        ErrCode = 1
	Unknown         ErrCode = 2
	InvalidArgument ErrCode = 3
)

func (ErrCode) ErrRep

func (x ErrCode) ErrRep() *ErrRep

func (ErrCode) Error

func (x ErrCode) Error() string

func (ErrCode) GRPCStatus added in v0.0.28

func (x ErrCode) GRPCStatus() *status.Status

example 实现

func (ErrCode) Msg added in v0.0.28

func (x ErrCode) Msg(msg string) *ErrRep

func (ErrCode) String

func (x ErrCode) String() string

func (ErrCode) Wrap added in v0.0.27

func (x ErrCode) Wrap(err error) *ErrRep

type ErrRep

type ErrRep struct {
	Code ErrCode `json:"code"`
	Msg  string  `json:"msg,omitempty"`
}

func FromError added in v0.0.28

func FromError(err error) (s *ErrRep, ok bool)

func NewErrRep

func NewErrRep(code ErrCode, msg string) *ErrRep

func (*ErrRep) AppendErr

func (x *ErrRep) AppendErr(err error) *ErrRep

func (*ErrRep) Error

func (x *ErrRep) Error() string

func (*ErrRep) GRPCStatus added in v0.0.28

func (x *ErrRep) GRPCStatus() *status.Status

func (*ErrRep) MarshalJSON

func (x *ErrRep) MarshalJSON() ([]byte, error)

func (*ErrRep) Wrap added in v0.0.27

func (x *ErrRep) Wrap(err error) *WrapErrRep

type GRPCStatus added in v0.0.28

type GRPCStatus interface {
	GRPCStatus() *status.Status
}

type IErrRep

type IErrRep interface {
	ErrRep() *ErrRep
}

type WarpErrCode

type WarpErrCode struct {
	ErrCode
	// contains filtered or unexported fields
}

func (*WarpErrCode) Error

func (x *WarpErrCode) Error() string

func (*WarpErrCode) Unwrap

func (x *WarpErrCode) Unwrap() error

type WarpError

type WarpError struct {
	Message string
	// contains filtered or unexported fields
}

func (*WarpError) Error

func (e *WarpError) Error() string

func (*WarpError) Unwrap

func (e *WarpError) Unwrap() error

type WrapErrRep added in v0.0.27

type WrapErrRep struct {
	ErrRep
	// contains filtered or unexported fields
}

func (*WrapErrRep) Error added in v0.0.27

func (e *WrapErrRep) Error() string

func (*WrapErrRep) Unwrap added in v0.0.27

func (e *WrapErrRep) Unwrap() error

Jump to

Keyboard shortcuts

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