- core/: database/redis_client/jwt/password/response/exceptions/security/logger/deps/middleware/app - create_app 迁移到 core/app.py,中间件注册顺序与异常处理器原样保留 - extensions/ utils/ apps/ 旧文件全部改为 re-export 垫片,import 路径保持兼容 - 新增 core 单元测试(jwt/password/response/request 共 12 个) Co-Authored-By: Claude <noreply@anthropic.com>
28 lines
970 B
Python
28 lines
970 B
Python
# +======================================================================
|
|
# | DjangoAdmin 企业数字化开发平台 [ 赋能开发者,助力企业发展 ]
|
|
# +----------------------------------------------------------------------
|
|
# | Copyright (c) 2021-2026 一米阳光团队 版权所有
|
|
# | 开源协议: Apache-2.0
|
|
# +======================================================================
|
|
# 由 extensions/exception.py 迁移而来。
|
|
|
|
"""统一异常类型:登录认证异常 + 业务异常。"""
|
|
|
|
|
|
class AuthorizationException(Exception):
|
|
"""登录认证异常,由 login_required 中间件抛出。"""
|
|
|
|
def __init__(self, code: int, msg: str):
|
|
super().__init__(msg)
|
|
self.code = code
|
|
self.msg = msg
|
|
|
|
|
|
class BusinessException(Exception):
|
|
"""业务异常,业务代码可主动抛出。"""
|
|
|
|
def __init__(self, code: int = 1, msg: str = ""):
|
|
super().__init__(msg)
|
|
self.code = code
|
|
self.msg = msg
|