Skip to content

Commit

Permalink
Merge pull request #18 from HumanCompatibleAI/fix-http-exception
Browse files Browse the repository at this point in the history
Better http exception handling
  • Loading branch information
raindrift authored Nov 6, 2024
2 parents 5a1f50c + 6dcf273 commit 25ca0e4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions perspective_ranker.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,13 @@ async def score(self, attributes, statement, statement_id):
return result

except aiohttp.ClientResponseError as e:
logger.error(f"HTTP error {e.status} {e.message} occurred for statement_id {statement_id}: {await response.text()}")
raise
logger.error(f"HTTP error {e.status} {e.message} occurred for statement_id {statement_id}")
try:
# try to get the response text
logger.error(f"HTTP error response text: {await response.text()}")
except Exception:
pass
raise e

except Exception as e:
logger.error(
Expand Down

0 comments on commit 25ca0e4

Please sign in to comment.