Skip to content

Commit

Permalink
github: Also catch ContentTypeError
Browse files Browse the repository at this point in the history
Try to get some more info from this trace

  File "/home/jerry/revup/revup/github_real.py", line 78, in graphql
    r = await resp.json()
  File "/home/jerry/.local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1165, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://api.github.com/graphql')
  • Loading branch information
jerry-skydio committed Feb 5, 2024
1 parent 8298f2c commit e43bfcf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions revup/github_real.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import time
from typing import Any, Optional, Tuple, Union

from aiohttp import ClientSession
from aiohttp import ClientSession, ContentTypeError

from revup import github
from revup.types import RevupGithubException, RevupRequestException
Expand Down Expand Up @@ -76,8 +76,8 @@ async def graphql(self, query: str, **kwargs: Any) -> Any:
)
try:
r = await resp.json()
except ValueError:
logging.debug("Response body:\n{}".format(await resp.text()))
except (ValueError, ContentTypeError):
logging.warning("Response body:\n{}".format(await resp.text()))
raise
else:
pretty_json = json.dumps(r, indent=1)
Expand Down

0 comments on commit e43bfcf

Please sign in to comment.