errors

package
v0.0.0-...-592b0ac Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DEVICE_ERROR = 2000000
View Source
const SYS_ERROR = 100000
View Source
const USER_ERROR = 1000000

Variables

View Source
var (
	RespParam     = NewCodeError(DEVICE_ERROR+1, "返回参数不对")
	DeviceTimeOut = NewCodeError(DEVICE_ERROR+2, "设备回复超时")
)
View Source
var (
	OK               = NewCodeError(0, "成功")
	Default          = NewCodeError(SYS_ERROR+1, "其他错误")
	TokenExpired     = NewCodeError(SYS_ERROR+2, "token 已经过期")
	TokenNotValidYet = NewCodeError(SYS_ERROR+3, "token还未生效")
	TokenMalformed   = NewCodeError(SYS_ERROR+4, "这不是一个token")
	TokenInvalid     = NewCodeError(SYS_ERROR+5, "违法的token")
	Parameter        = NewCodeError(SYS_ERROR+6, "参数错误")
	System           = NewCodeError(SYS_ERROR+7, "系统错误")
	Database         = NewCodeError(SYS_ERROR+8, "数据库错误")
	NotFind          = NewCodeError(SYS_ERROR+9, "未查询到")
	Duplicate        = NewCodeError(SYS_ERROR+10, "参数重复")
	SignatureExpired = NewCodeError(SYS_ERROR+11, "签名已经过期")
	Permissions      = NewCodeError(SYS_ERROR+12, "权限不足")
	Method           = NewCodeError(SYS_ERROR+13, "method不支持")
	Type             = NewCodeError(SYS_ERROR+14, "参数的类型不对")
	OutRange         = NewCodeError(SYS_ERROR+15, "参数的值超出范围")
	TimeOut          = NewCodeError(SYS_ERROR+16, "等待超时")
	Server           = NewCodeError(SYS_ERROR+17, "本实例处理不了该信息")
)
View Source
var (
	DuplicateUsername  = NewCodeError(USER_ERROR+1, "用户名已经注册")
	DuplicateMobile    = NewCodeError(USER_ERROR+2, "手机号已经被占用")
	UnRegister         = NewCodeError(USER_ERROR+3, "未注册")
	Password           = NewCodeError(USER_ERROR+4, "账号或密码错误")
	Captcha            = NewCodeError(USER_ERROR+5, "验证码错误")
	UidNotCompare      = NewCodeError(USER_ERROR+6, "uid不对应")
	RegisterOne        = NewCodeError(USER_ERROR+22, "注册第一步未成功")
	DuplicateRegister  = NewCodeError(USER_ERROR+23, "重复注册")
	NeedUserName       = NewCodeError(USER_ERROR+24, "需要填入用户名")
	PasswordLevel      = NewCodeError(USER_ERROR+25, "密码强度不够")
	GetInfoPartFailure = NewCodeError(USER_ERROR+26, "获取用户信息有失败")
)

Functions

func Cmp

func Cmp(err1 error, err2 error) bool

func ErrorInterceptor

func ErrorInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

func NewDefaultError

func NewDefaultError(msg string) error

func ToRpc

func ToRpc(err error) error

Types

type CodeError

type CodeError struct {
	Code    int64    `json:"code"`
	Msg     string   `json:"msg"`
	Details []string `json:"details,omitempty"`
	Stack   []string `json:"strck,omitempty"`
}

func Fmt

func Fmt(errs error) *CodeError

将普通的error及转换成json的error或error类型的转回自己的error

func NewCodeError

func NewCodeError(code int64, msg string) *CodeError

func (CodeError) AddDetail

func (c CodeError) AddDetail(msg ...interface{}) *CodeError

func (CodeError) AddDetailf

func (c CodeError) AddDetailf(format string, a ...interface{}) *CodeError

func (CodeError) Error

func (e CodeError) Error() string

func (*CodeError) GetDetailMsg

func (c *CodeError) GetDetailMsg() string

func (CodeError) ToRpc

func (c CodeError) ToRpc() error

func (CodeError) WithMsg

func (c CodeError) WithMsg(msg string) *CodeError

type RpcError

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

Jump to

Keyboard shortcuts

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