errcode

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: MIT Imports: 7 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterErrCode

func RegisterErrCode(code ErrCode, msg string)

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

Types

type ErrCode

type ErrCode uint32
const (
	// SysErr ErrCode = -1
	Success ErrCode = 0
)

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) Log

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

func (ErrCode) MarshalJSON

func (x ErrCode) MarshalJSON() ([]byte, error)

func (ErrCode) Message

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

func (ErrCode) Response

func (x ErrCode) Response(w http.ResponseWriter)

func (ErrCode) String

func (x ErrCode) String() string

func (ErrCode) Warp

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

type ErrRep

type ErrRep struct {
	Code    ErrCode `json:"code"`
	Message string  `json:"message,omitempty"`
}

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) Response

func (x *ErrRep) Response(w http.ResponseWriter)

func (*ErrRep) Warp

func (x *ErrRep) Warp(err error) *WarpErrRep

type GrpcStatus

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 WarpErrRep

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

func (*WarpErrRep) Error

func (e *WarpErrRep) Error() string

func (*WarpErrRep) Unwrap

func (e *WarpErrRep) 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

Jump to

Keyboard shortcuts

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