-
Notifications
You must be signed in to change notification settings - Fork 0
/
err_def.go
91 lines (84 loc) · 2.31 KB
/
err_def.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package common
type WebError struct {
code string
errMsg string
}
func (err *WebError) Error() string {
if err != nil {
return err.errMsg
}
return ""
}
func (err *WebError) Code() string {
if err != nil {
return err.code
}
return ""
}
func GetWebMsgCode(errMsg string) string {
return errCodeM[errMsg]
}
func GetWebErrorFromErrMsg(errMsg string) *WebError {
return &WebError{
code: GetWebMsgCode(errMsg),
errMsg: errMsg,
}
}
const (
Nil = "" //无msg,非正常情况,需要debug
SuccessMsg = "success"
CheckAuthErrMsg = "权限不足,请先登录"
TokenRevokedErrMsg = "已在其他地方登陆"
TokenExpireErrMsg = "登陆过期"
QueryBindErrMsg = "query参数解析错误"
ReqIllegal = "非法的Req"
AccountErrMsg = "账号或密码错误"
InternalErrMsg = "服务内部错误"
TokenRevokeMsg = "token revoked"
CodeErrMsg = "验证码错误"
CodeMinuteErrMsg = "1分钟只能发送一条短信"
MemHasErrMsg = "用户已存在"
DetailMaxErrMsg = "已达每日阅读上限"
// req check
ReqAccountErrMsg = "帐号不能为空"
ReqMobileErrMsg = "非法的手机号"
ReqMobileHasErrMsg = "手机号已存在"
ReqEmailErrMsg = "非法的邮箱"
ReqOverLen = "参数长度过长"
//wechat
WechatOfficialErrMsg = "微信服务错误"
WechatPayErrMsg = "微信支付失败"
WechatOrderReqErrMsg = "非法的订单请求"
WechatQRLoginErrMsg = "尚未微信扫码登录"
// SEO
SEOErrMsg = "SEO500"
)
var errCodeM = map[string]string{
Nil: "000000",
//200
SuccessMsg: "200200",
ReqIllegal: "200202",
AccountErrMsg: "200203",
TokenRevokeMsg: "200205",
CodeErrMsg: "200206",
ReqAccountErrMsg: "200207",
ReqMobileErrMsg: "200208",
ReqEmailErrMsg: "200209",
ReqOverLen: "200210",
WechatOfficialErrMsg: "200211",
WechatPayErrMsg: "200212",
WechatOrderReqErrMsg: "200213",
WechatQRLoginErrMsg: "200214",
MemHasErrMsg: "200215",
DetailMaxErrMsg: "200216",
CodeMinuteErrMsg: "200217",
ReqMobileHasErrMsg: "200218",
//401
CheckAuthErrMsg: "401233",
TokenRevokedErrMsg: "401234",
TokenExpireErrMsg: "401235",
//500
QueryBindErrMsg: "500502",
InternalErrMsg: "500501",
SEOErrMsg: "500503",
}