kooktaeeee / error_handler.py
taekooktea's picture
Update error_handler.py
4a410d7 verified
raw
history blame contribute delete
337 Bytes
from fastapi import HTTPException
def handle_generation_error(error: Exception, user_input: str):
error_msg = f"推理失败(输入:{user_input}),错误原因:{str(error)[:100]}"
print(error_msg)
raise HTTPException(
status_code=500,
detail={"error": "AI回复生成失败", "msg": error_msg}
)