Skip to content

Commit

Permalink
✨ Enhance error handling in error_handling_wrapper: log JSONDecodeErr…
Browse files Browse the repository at this point in the history
…or only for non-heartbeat messages to improve debugging clarity.
  • Loading branch information
yym68686 committed Jan 23, 2025
1 parent 58a64e2 commit cd050a9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,9 @@ async def error_handling_wrapper(generator, channel_id, engine, stream, error_tr
try:
first_item_str = json.loads(first_item_str)
except json.JSONDecodeError:
logger.error(f"provider: {channel_id:<11} error_handling_wrapper JSONDecodeError! {repr(first_item_str)}")
raise StopAsyncIteration
if not first_item_str.startswith(": heartbeat"):
logger.error(f"provider: {channel_id:<11} error_handling_wrapper JSONDecodeError! {repr(first_item_str)}")
raise StopAsyncIteration
if isinstance(first_item_str, dict) and 'error' in first_item_str and first_item_str.get('error') != {"message": "","type": "","param": "","code": None}:
# 如果第一个 yield 的项是错误信息,抛出 HTTPException
status_code = first_item_str.get('status_code', 500)
Expand Down

0 comments on commit cd050a9

Please sign in to comment.