aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris <[email protected]>2021-01-29 22:16:51 +0000
committerGravatar Chris <[email protected]>2021-01-29 22:16:51 +0000
commit3f0565b04fa08f7d799bc5b05af6f0926800aaa1 (patch)
tree0ee71031cf14eebc44097412dc13ef7d06350901
parentcatch the response error and deal with it (diff)
handle within the error handler
-rw-r--r--bot/converters.py5
-rw-r--r--bot/exts/backend/error_handler.py6
2 files changed, 7 insertions, 4 deletions
diff --git a/bot/converters.py b/bot/converters.py
index 880b1fe38..d0a9731d6 100644
--- a/bot/converters.py
+++ b/bot/converters.py
@@ -575,10 +575,7 @@ class Infraction(Converter):
return infractions[0]
else:
- try:
- return await ctx.bot.api_client.get(f"bot/infractions/{arg}")
- except ResponseCodeError:
- raise BadArgument("The provided infraction could not be found.")
+ return await ctx.bot.api_client.get(f"bot/infractions/{arg}")
Expiry = t.Union[Duration, ISODateTime]
diff --git a/bot/exts/backend/error_handler.py b/bot/exts/backend/error_handler.py
index b8bb3757f..8923a6b3d 100644
--- a/bot/exts/backend/error_handler.py
+++ b/bot/exts/backend/error_handler.py
@@ -85,6 +85,12 @@ class ErrorHandler(Cog):
else:
await self.handle_unexpected_error(ctx, e.original)
return # Exit early to avoid logging.
+ elif isinstance(e, errors.ConversionError):
+ if isinstance(e.original, ResponseCodeError):
+ await self.handle_api_error(ctx, e.original)
+ else:
+ await self.handle_unexpected_error(ctx, e.original)
+ return # Exit early to avoid logging.
elif not isinstance(e, errors.DisabledCommand):
# ConversionError, MaxConcurrencyReached, ExtensionError
await self.handle_unexpected_error(ctx, e)