mirror of
https://github.com/miaowware/qrm2.git
synced 2026-08-14 23:43:30 -04:00
Improved error handling in commands
- Changed all "status != 200" to raise a custom exception - Raise appropriate exceptions in 'grid' - Removed command-specific error handling in 'extctl' commands Fixes #146
This commit is contained in:
+2
-6
@@ -110,11 +110,7 @@ class StudyCog(commands.Cog):
|
||||
|
||||
async with self.session.get(f'https://hamstudy.org/pools/{pool}') as resp:
|
||||
if resp.status != 200:
|
||||
embed.title = 'Error in HamStudy command'
|
||||
embed.description = 'Could not load questions'
|
||||
embed.colour = cmn.colours.bad
|
||||
await ctx.send(embed=embed)
|
||||
return
|
||||
raise cmn.BotHTTPError(resp)
|
||||
pool = json.loads(await resp.read())['pool']
|
||||
|
||||
# Select a question
|
||||
@@ -172,7 +168,7 @@ class StudyCog(commands.Cog):
|
||||
async def hamstudy_get_pools(self):
|
||||
async with self.session.get('https://hamstudy.org/pools/') as resp:
|
||||
if resp.status != 200:
|
||||
raise ConnectionError
|
||||
raise cmn.BotHTTPError(resp)
|
||||
else:
|
||||
pools_dict = json.loads(await resp.read())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user