yym68686 commited on
Commit
2bbc8bb
·
1 Parent(s): 68bdecb

Fix the bug of excessively long error logs.

Browse files
Files changed (1) hide show
  1. utils.py +1 -4
utils.py CHANGED
@@ -44,11 +44,8 @@ async def error_handling_wrapper(generator, status_code=200):
44
  first_item_str = first_item_str[5:]
45
  first_item_str = json.loads(first_item_str)
46
  if isinstance(first_item_str, dict) and 'error' in first_item_str:
47
- print('\033[31m')
48
- print(f"first_item_str: {first_item_str}")
49
- print('\033[0m')
50
  # 如果第一个 yield 的项是错误信息,抛出 HTTPException
51
- raise HTTPException(status_code=status_code, detail=first_item_str)
52
 
53
  # 如果不是错误,创建一个新的生成器,首先yield第一个项,然后yield剩余的项
54
  async def new_generator():
 
44
  first_item_str = first_item_str[5:]
45
  first_item_str = json.loads(first_item_str)
46
  if isinstance(first_item_str, dict) and 'error' in first_item_str:
 
 
 
47
  # 如果第一个 yield 的项是错误信息,抛出 HTTPException
48
+ raise HTTPException(status_code=status_code, detail=f"{first_item_str}"[:100])
49
 
50
  # 如果不是错误,创建一个新的生成器,首先yield第一个项,然后yield剩余的项
51
  async def new_generator():