feat: 人设模板系统、节点调度标签、pydantic-settings收敛、错误处理增强
新增persona_template表和CRUD API,BaseIndividualModel增加node_affinity和template_origin_id字段, WorkerCluster支持多集群Ray资源调度,环境变量收敛到pydantic-settings统一校验, 数据库异常转换为结构化BusinessError/RetryableError,系统节点支持custom_system_prompt。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
|
||||
from sqlalchemy.exc import IntegrityError, OperationalError
|
||||
from pydantic import ValidationError
|
||||
from kilostar.utils.error import UserNotExistError
|
||||
from kilostar.utils.error import UserNotExistError, BusinessError, RetryableError
|
||||
|
||||
from kilostar.utils.logger import get_logger
|
||||
|
||||
@@ -31,14 +31,16 @@ def database_exception(func):
|
||||
logger.error(f"对象校验失败:{e}")
|
||||
raise e
|
||||
except IntegrityError as e:
|
||||
logger.error(f"数据库完整性错误 (如重复记录): {e}")
|
||||
raise e
|
||||
logger.warning(f"数据库完整性冲突: {e.orig}")
|
||||
err = BusinessError(str(e.orig))
|
||||
err.http_status = 409
|
||||
err.code = "conflict"
|
||||
raise err from e
|
||||
except OperationalError as e:
|
||||
logger.error(f"数据库连接异常: {e}")
|
||||
raise e
|
||||
except UserNotExistError as e:
|
||||
logger.error(f"更改密码失败,用户不存在:{e}")
|
||||
raise e
|
||||
raise RetryableError(f"数据库暂时不可用,请稍后重试: {e}") from e
|
||||
except (UserNotExistError, BusinessError):
|
||||
raise
|
||||
except Exception as e:
|
||||
logger.exception(f"未预期的数据库错误: {e}")
|
||||
raise e
|
||||
|
||||
Reference in New Issue
Block a user