diff --git a/apps/api/app/api/routes/lipsync.py b/apps/api/app/api/routes/lipsync.py index e7593626e..8ca88f601 100644 --- a/apps/api/app/api/routes/lipsync.py +++ b/apps/api/app/api/routes/lipsync.py @@ -31,7 +31,14 @@ def _get_service( db: Session = Depends(get_db_session), cosyvoice_service: CosyVoiceService = Depends(get_cosyvoice_service), ) -> LipsyncService: - return LipsyncService(db, cosyvoice_service=cosyvoice_service) + try: + return LipsyncService(db, cosyvoice_service=cosyvoice_service) + except Exception as exc: + logger.error("LipsyncService 初始化失败: %s", exc, exc_info=True) + raise HTTPException( + status_code=500, + detail=f"LipsyncService init: {type(exc).__name__}: {exc}", + ) from exc def _resolve_voice_id( @@ -129,13 +136,20 @@ def list_lipsync_jobs( svc: LipsyncService = Depends(_get_service), ): """获取对口型任务列表.""" - items, total = svc.list_jobs( - user_id=current_user.id, - project_id=project_id, - status=status, - offset=offset, - limit=limit, - ) + try: + items, total = svc.list_jobs( + user_id=current_user.id, + project_id=project_id, + status=status, + offset=offset, + limit=limit, + ) + except Exception as exc: + logger.error("list_jobs 查询失败: %s", exc, exc_info=True) + raise HTTPException( + status_code=500, + detail=f"list_jobs error: {type(exc).__name__}: {exc}", + ) from exc return { "items": [LipsyncJobResponse.model_validate(j) for j in items], "total": total,