mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Docs] Fixes the docs for commands.Command.error (#2760)
* docfix * inline code for sphinx, not a ref
This commit is contained in:
parent
61b5730c48
commit
682ee1a459
@ -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
|
||||
-----------
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user