From 682ee1a459aa8eb21dd256508c7f262c12cbaf65 Mon Sep 17 00:00:00 2001 From: Michael H Date: Tue, 4 Jun 2019 14:21:30 -0400 Subject: [PATCH] [Docs] Fixes the docs for `commands.Command.error` (#2760) * docfix * inline code for sphinx, not a ref --- redbot/core/commands/commands.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/redbot/core/commands/commands.py b/redbot/core/commands/commands.py index 17cc4b0a0..e4a2cd2d6 100644 --- a/redbot/core/commands/commands.py +++ b/redbot/core/commands/commands.py @@ -420,6 +420,10 @@ class Command(CogCommandMixin, commands.Command): To have red handle specific errors with the default behavior, call ``Red.on_command_error`` with ``unhandled_by_cog`` set to True. + Due to how discord.py wraps exceptions, the exception you are expecting here + is likely in ``error.original`` despite that the normal event handler for bot + wide command error handling has no such wrapping. + For example: .. code-block:: python @@ -427,10 +431,10 @@ class Command(CogCommandMixin, commands.Command): @a_command.error async def a_command_error_handler(self, ctx, error): - if isisntance(error, MyErrrorType): - self.log_exception(error) + if isinstance(error.original, MyErrrorType): + self.log_exception(error.original) else: - await ctx.bot.on_command_error(ctx, error, unhandled_by_cog=True) + await ctx.bot.on_command_error(ctx, error.original, unhandled_by_cog=True) Parameters -----------