errcode

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: MIT, Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

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

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

example 实现

func (ErrCode) Msg

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

func (ErrCode) String

func (x ErrCode) String() string

func (ErrCode) WithHttpStatus

func (code ErrCode) WithHttpStatus(status int)

func (ErrCode) Wrap

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

type ErrRep

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

func ErrRepFrom

func ErrRepFrom(err error) *ErrRep

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

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

func (*ErrRep) MarshalJSON

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

func (*ErrRep) Wrap

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

type GRPCStatus

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

type Generic

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

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

func (*WrapErrRep) Error

func (e *WrapErrRep) Error() string

func (*WrapErrRep) Unwrap

func (e *WrapErrRep) Unwrap() error

Jump to

Keyboard shortcuts

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