You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
2.3 KiB
44 lines
2.3 KiB
package constant
|
|
|
|
type ErrorCode int
|
|
|
|
type ErrCodeInfo struct {
|
|
Code ErrorCode `json:"code"`
|
|
Msg string `json:"msg"`
|
|
}
|
|
|
|
const (
|
|
Success ErrorCode = 0 //成功 [SUCCESS]
|
|
IllegalAccess ErrorCode = 600000 //未登陆或非法访问
|
|
AuthorizationExpired ErrorCode = 600001 //授权已经过期
|
|
ErrorInfo ErrorCode = 600002 //错误信息
|
|
ParamInvalid ErrorCode = 601000 //无效的请求参数 [Invalid request parameters]
|
|
ServerError ErrorCode = 601001 //服务器内部错误 [Server internal error]
|
|
NotFound ErrorCode = 601002 //not found
|
|
RecordNotFound ErrorCode = 601003 //记录没有发现
|
|
ErrorUserNameOrPassword ErrorCode = 601004 //用户名或密码错误
|
|
SaveFailed ErrorCode = 601005 //保存失败
|
|
EncryptionDataFailed ErrorCode = 601006 //加密用户数据失败
|
|
CheckSuccess ErrorCode = 601007 //检测配置成功
|
|
CheckFail ErrorCode = 601008 //检测配置成功
|
|
FireReqLimit ErrorCode = 601009 //请求达到限制阈值
|
|
RepeatName ErrorCode = 604003 //该名称已存在
|
|
)
|
|
|
|
var ErrCode = map[ErrorCode]ErrCodeInfo{
|
|
Success: ErrCodeInfo{Success, "SUCCESS"},
|
|
IllegalAccess: ErrCodeInfo{IllegalAccess, "No login or illegal access"},
|
|
AuthorizationExpired: ErrCodeInfo{AuthorizationExpired, "authorization expired"},
|
|
ErrorInfo: ErrCodeInfo{ErrorInfo, "error message"},
|
|
ParamInvalid: ErrCodeInfo{ParamInvalid, "Invalid request parameters"},
|
|
ServerError: ErrCodeInfo{ServerError, "Server internal error"},
|
|
NotFound: ErrCodeInfo{NotFound, "not found"},
|
|
RecordNotFound: ErrCodeInfo{RecordNotFound, "record not found"},
|
|
ErrorUserNameOrPassword: ErrCodeInfo{RecordNotFound, "error username or password"},
|
|
SaveFailed: ErrCodeInfo{SaveFailed, "save failed"},
|
|
EncryptionDataFailed: ErrCodeInfo{EncryptionDataFailed, "Encryption Data Failed"},
|
|
CheckSuccess: ErrCodeInfo{EncryptionDataFailed, "check success"},
|
|
CheckFail: ErrCodeInfo{EncryptionDataFailed, "check fail"},
|
|
FireReqLimit: ErrCodeInfo{Code: FireReqLimit, Msg: "request times limit"},
|
|
RepeatName: ErrCodeInfo{Code: RepeatName, Msg: "request param repeat name"},
|
|
}
|