From 4d2f89991432639431968d352bde2cd747b9432c Mon Sep 17 00:00:00 2001 From: Rohan Date: Wed, 2 Dec 2020 21:58:09 +0530 Subject: Modify error handler check for locally handled errors. Error handler now checks if the error has the attribute "handled" for locally handled errors. --- bot/exts/evergreen/error_handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot/exts/evergreen/error_handler.py') diff --git a/bot/exts/evergreen/error_handler.py b/bot/exts/evergreen/error_handler.py index 6e518435..b502dd4e 100644 --- a/bot/exts/evergreen/error_handler.py +++ b/bot/exts/evergreen/error_handler.py @@ -42,8 +42,8 @@ class CommandErrorHandler(commands.Cog): @commands.Cog.listener() async def on_command_error(self, ctx: commands.Context, error: commands.CommandError) -> None: """Activates when a command opens an error.""" - if hasattr(ctx.command, 'on_error'): - logging.debug("A command error occured but the command had it's own error handler.") + if hasattr(error, 'handled'): + logging.debug(f"Command {ctx.command} had its error already handled locally; ignoring.") return error = getattr(error, 'original', error) -- cgit v1.2.3 From cd24f9b4e70ebe654fa771238fca7e207e8cb0de Mon Sep 17 00:00:00 2001 From: Rohan Date: Fri, 4 Dec 2020 20:33:03 +0530 Subject: Check value of handled attribute on error in global error handler. --- bot/exts/evergreen/error_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot/exts/evergreen/error_handler.py') diff --git a/bot/exts/evergreen/error_handler.py b/bot/exts/evergreen/error_handler.py index b502dd4e..99af1519 100644 --- a/bot/exts/evergreen/error_handler.py +++ b/bot/exts/evergreen/error_handler.py @@ -42,7 +42,7 @@ class CommandErrorHandler(commands.Cog): @commands.Cog.listener() async def on_command_error(self, ctx: commands.Context, error: commands.CommandError) -> None: """Activates when a command opens an error.""" - if hasattr(error, 'handled'): + if getattr(error, 'handled', False): logging.debug(f"Command {ctx.command} had its error already handled locally; ignoring.") return -- cgit v1.2.3