[commands] Cleanup Command.invoke code due to exception propagation.
This commit is contained in:
parent
33a69681fc
commit
24a9da04db
@ -352,7 +352,6 @@ class Command:
|
|||||||
args.append(transformed)
|
args.append(transformed)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
break
|
break
|
||||||
return True
|
|
||||||
|
|
||||||
def _verify_checks(self, ctx):
|
def _verify_checks(self, ctx):
|
||||||
if not self.enabled:
|
if not self.enabled:
|
||||||
@ -363,16 +362,13 @@ class Command:
|
|||||||
|
|
||||||
if not self.can_run(ctx):
|
if not self.can_run(ctx):
|
||||||
raise CheckFailure('The check functions for command {0.name} failed.'.format(self))
|
raise CheckFailure('The check functions for command {0.name} failed.'.format(self))
|
||||||
return True
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def invoke(self, ctx):
|
def invoke(self, ctx):
|
||||||
if not self._verify_checks(ctx):
|
self._verify_checks(ctx)
|
||||||
return
|
yield from self._parse_arguments(ctx)
|
||||||
|
injected = inject_context(ctx, self.callback)
|
||||||
if (yield from self._parse_arguments(ctx)):
|
yield from injected(*ctx.args, **ctx.kwargs)
|
||||||
injected = inject_context(ctx, self.callback)
|
|
||||||
yield from injected(*ctx.args, **ctx.kwargs)
|
|
||||||
|
|
||||||
def error(self, coro):
|
def error(self, coro):
|
||||||
"""A decorator that registers a coroutine as a local error handler.
|
"""A decorator that registers a coroutine as a local error handler.
|
||||||
@ -587,9 +583,8 @@ class Group(GroupMixin, Command):
|
|||||||
def invoke(self, ctx):
|
def invoke(self, ctx):
|
||||||
early_invoke = not self.invoke_without_command
|
early_invoke = not self.invoke_without_command
|
||||||
if early_invoke:
|
if early_invoke:
|
||||||
valid = self._verify_checks(ctx) and (yield from self._parse_arguments(ctx))
|
self._verify_checks(ctx)
|
||||||
if not valid:
|
yield from self._parse_arguments(ctx)
|
||||||
return
|
|
||||||
|
|
||||||
view = ctx.view
|
view = ctx.view
|
||||||
previous = view.index
|
previous = view.index
|
||||||
@ -612,9 +607,8 @@ class Group(GroupMixin, Command):
|
|||||||
# undo the trigger parsing
|
# undo the trigger parsing
|
||||||
view.index = previous
|
view.index = previous
|
||||||
view.previous = previous
|
view.previous = previous
|
||||||
valid = self._verify_checks(ctx) and (yield from self._parse_arguments(ctx))
|
self._verify_checks(ctx)
|
||||||
if not valid:
|
yield from self._parse_arguments(ctx)
|
||||||
return
|
|
||||||
injected = inject_context(ctx, self.callback)
|
injected = inject_context(ctx, self.callback)
|
||||||
yield from injected(*ctx.args, **ctx.kwargs)
|
yield from injected(*ctx.args, **ctx.kwargs)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user