diff options
| author | 2021-01-29 22:16:51 +0000 | |
|---|---|---|
| committer | 2021-01-29 22:16:51 +0000 | |
| commit | 3f0565b04fa08f7d799bc5b05af6f0926800aaa1 (patch) | |
| tree | 0ee71031cf14eebc44097412dc13ef7d06350901 | |
| parent | catch the response error and deal with it (diff) | |
handle within the error handler
| -rw-r--r-- | bot/converters.py | 5 | ||||
| -rw-r--r-- | bot/exts/backend/error_handler.py | 6 |
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) |