Skip to content

Commit 25ca0e4

Browse files
authored
Merge pull request #18 from HumanCompatibleAI/fix-http-exception
Better http exception handling
2 parents 5a1f50c + 6dcf273 commit 25ca0e4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

perspective_ranker.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,13 @@ async def score(self, attributes, statement, statement_id):
263263
return result
264264

265265
except aiohttp.ClientResponseError as e:
266-
logger.error(f"HTTP error {e.status} {e.message} occurred for statement_id {statement_id}: {await response.text()}")
267-
raise
266+
logger.error(f"HTTP error {e.status} {e.message} occurred for statement_id {statement_id}")
267+
try:
268+
# try to get the response text
269+
logger.error(f"HTTP error response text: {await response.text()}")
270+
except Exception:
271+
pass
272+
raise e
268273

269274
except Exception as e:
270275
logger.error(

0 commit comments

Comments
 (0)