Browse Source

[commands] Guarantee that local error handler is called before generic.

pull/468/head
Rapptz 8 years ago
parent
commit
ea72d5e63d
  1. 2
      discord/ext/commands/bot.py
  2. 6
      discord/ext/commands/core.py

2
discord/ext/commands/bot.py

@ -632,7 +632,7 @@ class BotBase(GroupMixin):
try:
yield from ctx.command.invoke(ctx)
except CommandError as e:
ctx.command.dispatch_error(e, ctx)
yield from ctx.command.dispatch_error(e, ctx)
else:
self.dispatch('command_completion', ctx)
elif ctx.invoked_with:

6
discord/ext/commands/core.py

@ -145,18 +145,18 @@ class Command:
self.parent = None
self._buckets = CooldownMapping(kwargs.get('cooldown'))
@asyncio.coroutine
def dispatch_error(self, error, ctx):
try:
coro = self.on_error
except AttributeError:
pass
else:
loop = ctx.bot.loop
injected = wrap_callback(coro)
if self.instance is not None:
discord.compat.create_task(injected(self.instance, error, ctx), loop=loop)
yield from injected(self.instance, error, ctx)
else:
discord.compat.create_task(injected(error, ctx), loop=loop)
yield from injected(error, ctx)
finally:
ctx.bot.dispatch('command_error', error, ctx)

Loading…
Cancel
Save