Skip to content

Commit

Permalink
Re-raise BotError directly
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Sep 30, 2023
1 parent 07e977d commit 770d091
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/fastapi_poe/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ async def stream_request(
except Exception as e:
on_error(e, f"Bot request to {bot_name} failed on try {i}")
if got_response or i == num_tries - 1:
# If it's a BotError, it probably has a good error message
# that we want to show directly.
if isinstance(e, BotError):
raise
# But if it's something else (maybe an HTTP error or something),
# wrap it in a BotError that makes it clear which bot is broken.
raise BotError(f"Error communicating with bot {bot_name}") from e
await asyncio.sleep(retry_sleep_time)

Expand Down

0 comments on commit 770d091

Please sign in to comment.