aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Andi Qu <[email protected]>2021-01-13 19:19:49 +0200
committerGravatar Andi Qu <[email protected]>2021-01-13 19:19:49 +0200
commit08b793024f271de009aab2391cd85576af5313cf (patch)
tree9fb2be4d8f0ac11375c37a7c4d78be4601732666
parentBetter regex now works for <link> (diff)
Better error reporting in _fetch_response(?)
-rw-r--r--bot/exts/info/code_snippets.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/bot/exts/info/code_snippets.py b/bot/exts/info/code_snippets.py
index 1d1bc2850..3469b88f4 100644
--- a/bot/exts/info/code_snippets.py
+++ b/bot/exts/info/code_snippets.py
@@ -3,6 +3,7 @@ import re
import textwrap
from urllib.parse import quote_plus
+from aiohttp import ClientResponseError
from discord import Message
from discord.ext.commands import Cog
@@ -46,13 +47,13 @@ class CodeSnippets(Cog):
async def _fetch_response(self, url: str, response_format: str, **kwargs) -> str:
"""Makes http requests using aiohttp."""
try:
- async with self.bot.http_session.get(url, **kwargs) as response:
+ async with self.bot.http_session.get(url, raise_for_status=True, **kwargs) as response:
if response_format == 'text':
return await response.text()
elif response_format == 'json':
return await response.json()
- except Exception:
- log.exception(f'Failed to fetch code snippet from {url}.')
+ except ClientResponseError as error:
+ log.error(f'Failed to fetch code snippet from {url}. HTTP Status: {error.status}. Message: {str(error)}.')
def _find_ref(self, path: str, refs: tuple) -> tuple:
"""Loops through all branches and tags to find the required ref."""