Skip to content

Commit

Permalink
🐛 Bug: Fix the bug where error strings cannot be captured correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
yym68686 committed Dec 3, 2024
1 parent b530449 commit ede1c03
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,13 @@ async def error_handling_wrapper(generator, channel_id, engine, stream, error_tr
if first_item_str.startswith("[DONE]"):
logger.error(f"provider: {channel_id:<11} error_handling_wrapper [DONE]!")
raise StopAsyncIteration
if any(x in first_item_str for x in error_triggers):
logger.error(f"provider: {channel_id:<11} error const string: %s", first_item_str)
try:
encode_first_item_str = first_item_str.encode().decode('unicode-escape')
except UnicodeDecodeError:
encode_first_item_str = first_item_str
logger.error(f"provider: {channel_id:<11} error UnicodeDecodeError: %s", first_item_str)
if any(x in encode_first_item_str for x in error_triggers):
logger.error(f"provider: {channel_id:<11} error const string: %s", encode_first_item_str)
raise StopAsyncIteration
try:
first_item_str = json.loads(first_item_str)
Expand Down

0 comments on commit ede1c03

Please sign in to comment.