Skip to content

Commit

Permalink
在 main.py 中添加 traceback 导入,并在异常处理时使用 traceback.print_exc() 以改进错误日志记录
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiesun committed Nov 24, 2024
1 parent b830a22 commit cc75449
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
import sys
import uuid

import traceback
import aiofiles

from common.rediscache import RedisCache
Expand Down Expand Up @@ -476,7 +476,7 @@ async def translate_text(
result={"data": target}
)
except Exception as e:
log.error(e)
traceback.print_exc()
return RestResult(
code=500,
msg=str(e),
Expand Down Expand Up @@ -535,6 +535,7 @@ async def translate_document(

except Exception as e:
log.error(f"Document translation error: {str(e)}")
traceback.print_exc()
raise HTTPException(
status_code=500,
detail=f"Translation failed: {str(e)}"
Expand Down

0 comments on commit cc75449

Please sign in to comment.