[commands] Re-order error handler arguments.
They now have Context as the first argument to be consistent with other context-passing functions.
This commit is contained in:
parent
6b063deda9
commit
a2c9cefac9
@ -740,13 +740,13 @@ class BotBase(GroupMixin):
|
|||||||
try:
|
try:
|
||||||
yield from ctx.command.invoke(ctx)
|
yield from ctx.command.invoke(ctx)
|
||||||
except CommandError as e:
|
except CommandError as e:
|
||||||
yield from ctx.command.dispatch_error(e, ctx)
|
yield from ctx.command.dispatch_error(ctx, e)
|
||||||
else:
|
else:
|
||||||
ctx.command_failed = False
|
ctx.command_failed = False
|
||||||
self.dispatch('command_completion', ctx)
|
self.dispatch('command_completion', ctx)
|
||||||
elif ctx.invoked_with:
|
elif ctx.invoked_with:
|
||||||
exc = CommandNotFound('Command "{}" is not found'.format(ctx.invoked_with))
|
exc = CommandNotFound('Command "{}" is not found'.format(ctx.invoked_with))
|
||||||
self.dispatch('command_error', exc, ctx)
|
self.dispatch('command_error', ctx, exc)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def process_commands(self, message):
|
def process_commands(self, message):
|
||||||
|
@ -164,7 +164,7 @@ class Command:
|
|||||||
self._after_invoke = None
|
self._after_invoke = None
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def dispatch_error(self, error, ctx):
|
def dispatch_error(self, ctx, error):
|
||||||
cog = self.instance
|
cog = self.instance
|
||||||
try:
|
try:
|
||||||
coro = self.on_error
|
coro = self.on_error
|
||||||
@ -173,9 +173,9 @@ class Command:
|
|||||||
else:
|
else:
|
||||||
injected = wrap_callback(coro)
|
injected = wrap_callback(coro)
|
||||||
if cog is not None:
|
if cog is not None:
|
||||||
yield from injected(cog, error, ctx)
|
yield from injected(cog, ctx, error)
|
||||||
else:
|
else:
|
||||||
yield from injected(error, ctx)
|
yield from injected(ctx, error)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
local = getattr(cog, '_{0.__class__.__name__}__error'.format(cog))
|
local = getattr(cog, '_{0.__class__.__name__}__error'.format(cog))
|
||||||
@ -183,9 +183,9 @@ class Command:
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
wrapped = wrap_callback(local)
|
wrapped = wrap_callback(local)
|
||||||
yield from wrapped(error, ctx)
|
yield from wrapped(ctx, error)
|
||||||
finally:
|
finally:
|
||||||
ctx.bot.dispatch('command_error', error, ctx)
|
ctx.bot.dispatch('command_error', ctx, error)
|
||||||
|
|
||||||
def __get__(self, instance, owner):
|
def __get__(self, instance, owner):
|
||||||
if instance is not None:
|
if instance is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user