[commands] raise ConversionError on Converter error

This assumes that a Converter class raising non-CommandError
is a programmer error. Makes this type of error easier to
disambiguate from a generic BadArgument.
This commit is contained in:
khazhyk
2018-07-15 19:39:33 -07:00
committed by Rapptz
parent 87d9eefdef
commit 2321ae8d97
3 changed files with 47 additions and 26 deletions

View File

@ -30,7 +30,7 @@ __all__ = [ 'CommandError', 'MissingRequiredArgument', 'BadArgument',
'NoPrivateMessage', 'CheckFailure', 'CommandNotFound',
'DisabledCommand', 'CommandInvokeError', 'TooManyArguments',
'UserInputError', 'CommandOnCooldown', 'NotOwner',
'MissingPermissions', 'BotMissingPermissions']
'MissingPermissions', 'BotMissingPermissions', 'ConversionError']
class CommandError(DiscordException):
"""The base exception type for all command related errors.
@ -49,6 +49,19 @@ class CommandError(DiscordException):
else:
super().__init__(*args)
class ConversionError(CommandError):
"""Exception raised when a Converter class raises non-CommandError.
Attributes
----------
converter: :class:`discord.ext.commands.Converter`
The converter that failed.
This inherits from :exc:`.CommandError`.
"""
def __init__(self, converter):
self.converter = converter
class UserInputError(CommandError):
"""The base exception type for errors that involve errors
regarding user input.