[Docs] Fixes the docs for commands.Command.error (#2760)

* docfix

* inline code for sphinx, not a ref
This commit is contained in:
Michael H 2019-06-04 14:21:30 -04:00 committed by Kowlin
parent 61b5730c48
commit 682ee1a459

View File

@ -420,6 +420,10 @@ class Command(CogCommandMixin, commands.Command):
To have red handle specific errors with the default behavior, To have red handle specific errors with the default behavior,
call ``Red.on_command_error`` with ``unhandled_by_cog`` set to True. 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: For example:
.. code-block:: python .. code-block:: python
@ -427,10 +431,10 @@ class Command(CogCommandMixin, commands.Command):
@a_command.error @a_command.error
async def a_command_error_handler(self, ctx, error): async def a_command_error_handler(self, ctx, error):
if isisntance(error, MyErrrorType): if isinstance(error.original, MyErrrorType):
self.log_exception(error) self.log_exception(error.original)
else: 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 Parameters
----------- -----------