diff options
author | 2019-10-02 18:56:04 -0600 | |
---|---|---|
committer | 2019-10-02 18:56:04 -0600 | |
commit | 2bc08cc669e886fe749590e75d4030a5dbcb3f71 (patch) | |
tree | 2b92eb9229a64c0755bd5e9f801d1f2b12c52757 | |
parent | Add checks for valid response and retries to fetch_posts() (diff) |
Add logging for invalid response (after all retries are exhausted)
-rw-r--r-- | bot/cogs/reddit.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/bot/cogs/reddit.py b/bot/cogs/reddit.py index c626ad48c..5a5f43da9 100644 --- a/bot/cogs/reddit.py +++ b/bot/cogs/reddit.py @@ -43,9 +43,10 @@ class Reddit(Cog): if params is None: params = {} + url = f"{self.URL}/{route}.json" for _ in range(self.MAX_FETCH_RETRIES): response = await self.bot.http_session.get( - url=f"{self.URL}/{route}.json", + url=url, headers=self.HEADERS, params=params ) @@ -55,6 +56,7 @@ class Reddit(Cog): posts = content["data"]["children"] return posts[:amount] + log.debug(f"Invalid response from: {url} - status code {response.status}, mimetype {response.content_type}") return list() # Failed to get appropriate response within allowed number of retries. async def send_top_posts( |