39 lines
975 B
Go
39 lines
975 B
Go
package xerr
|
|
|
|
const (
|
|
OK = 0
|
|
ServerError = 1001
|
|
ParamError = 1002
|
|
TokenExpired = 1003
|
|
TokenInvalid = 1004
|
|
Unauthorized = 1005
|
|
Forbidden = 1006
|
|
RecordNotFound = 1007
|
|
RecordDuplicate = 1008
|
|
PasswordError = 1009
|
|
ImportError = 1010
|
|
OperationForbidden = 1011
|
|
)
|
|
|
|
var codeText = map[int]string{
|
|
OK: "success",
|
|
ServerError: "internal server error",
|
|
ParamError: "invalid parameters",
|
|
TokenExpired: "token expired",
|
|
TokenInvalid: "invalid token",
|
|
Unauthorized: "unauthorized",
|
|
Forbidden: "access denied",
|
|
RecordNotFound: "record not found",
|
|
RecordDuplicate: "record already exists",
|
|
PasswordError: "incorrect password",
|
|
ImportError: "import failed",
|
|
OperationForbidden: "operation not allowed",
|
|
}
|
|
|
|
func ErrMsg(code int) string {
|
|
if msg, ok := codeText[code]; ok {
|
|
return msg
|
|
}
|
|
return "unknown error"
|
|
}
|