dual check v0.1
This commit is contained in:
1 parent
78bad1fa3d
commit
c137299016
36 files changed
+3727
-81
No files matched your search
@@ -0,0 +1,31 @@
|
||||
package dual_check
|
||||
|
||||
// 业务错误码
|
||||
const (
|
||||
ErrCodeInvalidParam = 4000
|
||||
ErrCodeSessionNotFound = 1001
|
||||
ErrCodeSessionExpired = 1002
|
||||
ErrCodeDuplicateSubmit = 1003
|
||||
ErrCodeInvalidRole = 1004
|
||||
ErrCodeSessionCreate = 1005
|
||||
ErrCodeNicknameExists = 1006 // 昵称已被其他人占用(WS 连接时发现)
|
||||
ErrCodeNotInSession = 1007 // 该昵称未 join 会话就 submit
|
||||
)
|
||||
|
||||
var errorMessages = map[int]string{
|
||||
ErrCodeInvalidParam: "invalid parameter",
|
||||
ErrCodeSessionNotFound: "会话码不存在或已过期",
|
||||
ErrCodeSessionExpired: "session has expired",
|
||||
ErrCodeDuplicateSubmit: "该昵称已提交过文本",
|
||||
ErrCodeInvalidRole: "role must be 'initiator' or 'participant'",
|
||||
ErrCodeSessionCreate: "failed to create session, please retry",
|
||||
ErrCodeNicknameExists: "该昵称已在会话中,请换一个",
|
||||
ErrCodeNotInSession: "该昵称未加入会话",
|
||||
}
|
||||
|
||||
func ErrMessage(code int) string {
|
||||
if msg, ok := errorMessages[code]; ok {
|
||||
return msg
|
||||
}
|
||||
return "unknown error"
|
||||
}
|
||||
Reference in new issue
Block a user