hi-server/pkg/xerr/errMsg.go
shanshanzhong c5d59b86b0
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m20s
feat(用户绑定): 实现邮箱绑定功能并优化设备解绑逻辑
添加邮箱绑定错误码和消息
修改解绑设备逻辑,解绑后创建新用户设备记录
重构邮箱绑定逻辑,支持检测已绑定邮箱并处理设备转移
2025-10-31 00:14:22 -07:00

110 lines
3.8 KiB
Go

package xerr
var message map[uint32]string
func init() {
message = make(map[uint32]string)
message = map[uint32]string{
// General error
SUCCESS: "Success",
ERROR: "Internal Server Error",
// parameter error
TooManyRequests: "Too Many Requests",
InvalidParams: "Param Error",
ErrorTokenEmpty: "User token is empty",
ErrorTokenInvalid: "User token is invalid",
ErrorTokenExpire: "User token is expired",
SecretIsEmpty: "Secret is empty",
InvalidAccess: "Invalid access",
InvalidCiphertext: "Invalid ciphertext",
// Database error
DatabaseQueryError: "Database query error",
DatabaseUpdateError: "Database update error",
DatabaseInsertError: "Database insert error",
DatabaseDeletedError: "Database deleted error",
// User error
UserExist: "User already exists",
UserNotExist: "User does not exist",
UserPasswordError: "User password error",
UserDisabled: "User disabled",
InsufficientBalance: "Insufficient balance",
StopRegister: "Stop register",
TelegramNotBound: "Telegram not bound ",
UserNotBindOauth: "User not bind oauth method",
InviteCodeError: "Invite code error",
// 邮箱绑定错误
EmailBindError: "已经绑定该邮箱",
// Node error
NodeExist: "Node already exists",
NodeNotExist: "Node does not exist",
NodeGroupExist: "Node group already exists",
NodeGroupNotExist: "Node group does not exist",
NodeGroupNotEmpty: "Node group is not empty",
//coupon error
CouponNotExist: "Coupon does not exist",
CouponAlreadyUsed: "Coupon has already been used",
CouponNotApplicable: "Coupon does not match the order or conditions",
CouponInsufficientUsage: "Coupon has insufficient remaining uses",
CouponExpired: "Coupon is expired",
// Subscribe
SubscribeExpired: "Subscribe is expired",
SubscribeNotAvailable: "Subscribe is not available",
UserSubscribeExist: "User has subscription",
SubscribeIsUsedError: "Subscribe is used",
SingleSubscribeModeExceedsLimit: "Single subscribe mode exceeds limit",
SubscribeQuotaLimit: "Subscribe quota limit",
// auth error
VerifyCodeError: "Verify code error",
// EnqueueError
QueueEnqueueError: " Queue enqueue error",
// System error
DebugModeError: "Debug mode is enabled",
GetAuthenticatorError: "Unsupported login method",
AuthenticatorNotSupportedError: "The authenticator does not support this method",
TelephoneAreaCodeIsEmpty: "Telephone area code is empty",
TodaySendCountExceedsLimit: "This account has reached the limit of sending times today",
SmsNotEnabled: "Telephone login is not enabled",
EmailNotEnabled: "Email function is not enabled yet",
PasswordOrVerificationCodeRequired: "Password or verification code required",
EmailExist: "Email already exists",
TelephoneExist: "Telephone already exists",
DeviceExist: "device exists",
PasswordIsEmpty: "password is empty",
TelephoneError: "telephone number error",
DeviceNotExist: "Device does not exist",
UseridNotMatch: "Userid not match",
// Order error
OrderNotExist: "Order does not exist",
PaymentMethodNotFound: "Payment method not found",
OrderStatusError: "Order status error",
InsufficientOfPeriod: "Insufficient number of period",
}
}
func MapErrMsg(errCode uint32) string {
if msg, ok := message[errCode]; ok {
return msg
} else {
return "Internal Server Error"
}
}
func IsCodeErr(errCode uint32) bool {
if _, ok := message[errCode]; ok {
return true
} else {
return false
}
}