Skip to content

Commit

Permalink
fix: return None on json parsing error
Browse files Browse the repository at this point in the history
  • Loading branch information
ekkx committed Aug 28, 2024
1 parent cd7402b commit d421829
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions yaylib/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
SOFTWARE.
"""

from json.decoder import JSONDecodeError

import aiohttp

from .responses import ErrorResponse
Expand Down Expand Up @@ -583,9 +585,12 @@ async def raise_for_code(response: aiohttp.ClientResponse) -> None:
Raises:
ClientError:
"""
response_json = await response.json(content_type=None)
if response_json is None:
return
try:
response_json = await response.json(content_type=None)
if response_json is None:
return None
except JSONDecodeError:
return None

err = ErrorResponse(response_json)
if err.result is None or err.result != "error":
Expand Down

0 comments on commit d421829

Please sign in to comment.