Skip to content

Commit e530d73

Browse files
committed
exceptions translated to english
1 parent 076c58b commit e530d73

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

fastapi_user_auth/auth/exceptions.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,36 @@
88
class ErrorCode(IntegerChoices):
99
"""常用错误码"""
1010

11-
SUCCESS = (0, "成功")
12-
FAIL = (1, "失败")
13-
PARAMS_ERROR = (2, "参数错误")
14-
RETRY = (10, "重试")
15-
RETRY_LATER = (11, "稍后重试")
11+
SUCCESS = (0, "Success") # 成功
12+
FAIL = (1, "Fail") # 失败
13+
PARAMS_ERROR = (2, "Parameter error") # 参数错误
14+
RETRY = (10, "Retry") # 重试
15+
RETRY_LATER = (11, "Try again later") # 稍后重试
1616
# 用户相关错误
17-
USER_NOT_FOUND = (40100, "用户不存在")
18-
USER_PASSWORD_ERROR = (40101, "用户名或者密码错误")
19-
USER_IS_EXIST = (40102, "用户已存在")
20-
USER_NAME_IS_EXIST = (40103, "用户名已存在")
21-
USER_MOBILE_IS_EXIST = (40104, "用户手机号已存在")
22-
USER_EMAIL_IS_EXIST = (40105, "用户邮箱已存在")
17+
USER_NOT_FOUND = (40100, "User does not exist") # 用户不存在
18+
USER_PASSWORD_ERROR = (40101, "Username or password is incorrect") # 用户名或者密码错误
19+
USER_IS_EXIST = (40102, "User already exists") # 用户已存在
20+
USER_NAME_IS_EXIST = (40103, "Username already exists") # 用户名已存在
21+
USER_MOBILE_IS_EXIST = (40104, "User mobile phone number already exists") # 用户手机号已存在
22+
USER_EMAIL_IS_EXIST = (40105, "User mailbox already exists") # 用户邮箱已存在
2323

2424
# 用户权限相关
25-
USER_IS_NOT_LOGIN = (40200, "用户未登录")
26-
USER_IS_NOT_ACTIVE = (40201, "用户未激活")
27-
USER_PERMISSION_DENIED = (40203, "用户权限不足")
28-
USER_IS_NOT_ADMIN = (40204, "用户不是管理员")
25+
USER_IS_NOT_LOGIN = (40200, "User is not logged in") # 用户未登录
26+
USER_IS_NOT_ACTIVE = (40201, "User is not activated") # 用户未激活
27+
USER_PERMISSION_DENIED = (40203, "Insufficient user rights") # 用户权限不足
28+
USER_IS_NOT_ADMIN = (40204, "User is not an administrator") # 用户不是管理员
2929
# 系统错误
30-
SYSTEM_ERROR = (50000, "系统错误")
31-
SYSTEM_BUSY = (50001, "系统繁忙")
30+
SYSTEM_ERROR = (50000, "System error") # 系统错误
31+
SYSTEM_BUSY = (50001, "The system is busy") # 系统繁忙
3232

3333

3434
class ApiException(HTTPException):
3535
def __init__(
36-
self,
37-
detail: Any,
38-
status_code: int = 200,
39-
content: Any = None,
40-
headers: Optional[Dict[str, Any]] = None,
36+
self,
37+
detail: Any,
38+
status_code: int = 200,
39+
content: Any = None,
40+
headers: Optional[Dict[str, Any]] = None,
4141
) -> None:
4242
self.content = content
4343
super().__init__(status_code=status_code, detail=detail, headers=headers)
@@ -47,11 +47,11 @@ class ApiError(ApiException):
4747
"""API异常基类"""
4848

4949
def __init__(
50-
self,
51-
status: int = ErrorCode.FAIL,
52-
msg: str = "",
53-
headers: Optional[Dict[str, Any]] = None,
54-
**extra,
50+
self,
51+
status: int = ErrorCode.FAIL,
52+
msg: str = "",
53+
headers: Optional[Dict[str, Any]] = None,
54+
**extra,
5555
):
5656
self.status = status
5757
self.extra = extra

0 commit comments

Comments
 (0)