[commands] Add param attribute to MissingRequiredArgument

This should allow easier querying on what argument is missing.

Fixes #470.
This commit is contained in:
Rapptz 2017-02-12 13:53:28 -05:00
parent 47ef657fbd
commit 7bc3750c27
2 changed files with 9 additions and 2 deletions

View File

@ -226,7 +226,7 @@ class Command:
if param.kind == param.VAR_POSITIONAL:
raise RuntimeError() # break the loop
if required:
raise MissingRequiredArgument('{0.name} is a required argument that is missing.'.format(param))
raise MissingRequiredArgument(param)
return param.default
if consume_rest_is_special:

View File

@ -68,8 +68,15 @@ class CommandNotFound(CommandError):
class MissingRequiredArgument(UserInputError):
"""Exception raised when parsing a command and a parameter
that is required is not encountered.
Attributes
-----------
param: str
The argument that is missing.
"""
pass
def __init__(self, param):
self.param = param.name
super().__init__('{0.name} is a required argument that is missing.'.format(param))
class TooManyArguments(UserInputError):
"""Exception raised when the command was passed too many arguments and its