errcode

package
v0.0.0-...-404d2c9 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Success          = NewError(0, "成功")
	Fail             = NewError(10000000, "内部错误")
	InvalidParams    = NewError(10000001, "无效参数")
	Unauthorized     = NewError(10000002, "认证错误")
	NotFound         = NewError(10000003, "没有找到")
	Unknown          = NewError(10000004, "未知")
	DeadlineExceeded = NewError(10000005, "超出最后截止期限")
	AccessDenied     = NewError(10000006, "访问被拒绝")
	LimitExceed      = NewError(10000007, "访问限制")
	MethodNotAllowed = NewError(10000008, "不支持该方法")
)

Preset Error Codes

Functions

func RPCCode

func RPCCode(code int) codes.Code

RPCCode converts common error to RPC code

func RPCError

func RPCError(err *Error) error

RPCError converts common error to RPC error

Types

type CommonStatus

type CommonStatus struct {
	*status.Status
}

CommonStatus stands for GRPC status

func FromError

func FromError(err error) *CommonStatus

FromError convert common error to GRPC status

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error stands for RPC error

func NewError

func NewError(code int, msg string) *Error

NewError creates a new PRC Error

func (*Error) Code

func (e *Error) Code() int

Code return the error code

func (*Error) Msg

func (e *Error) Msg() string

Msg return the error message

Jump to

Keyboard shortcuts

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