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 ErrorInterceptor ¶
func ErrorInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
func NewDefaultError ¶
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 NewCodeError ¶
func (CodeError) AddDetailf ¶
func (*CodeError) GetDetailMsg ¶
Click to show internal directories.
Click to hide internal directories.