errcode

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT, Apache-2.0 Imports: 5 Imported by: 11

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 Register added in v0.8.2

func Register(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
	DeadlineExceeded   ErrCode = 4
	NotFound           ErrCode = 5
	AlreadyExists      ErrCode = 6
	PermissionDenied   ErrCode = 7
	ResourceExhausted  ErrCode = 8
	FailedPrecondition ErrCode = 9
	Aborted            ErrCode = 10
	OutOfRange         ErrCode = 11
	Unimplemented      ErrCode = 12
	Internal           ErrCode = 13
	Unavailable        ErrCode = 14
	DataLoss           ErrCode = 15
	Unauthenticated    ErrCode = 16
)

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) HttpStatus added in v0.8.1

func (code ErrCode) HttpStatus() int

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 Generic added in v0.8.3

type Generic interface {
	~int | ~int32 | ~int64 | ~uint | ~uint32 | ~uint64
}

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