Rename InvaldiDestination to a generic ClientException.

This commit is contained in:
Rapptz 2015-10-27 18:45:45 -04:00
parent 61e41ec3b9
commit d14bffcd96
3 changed files with 9 additions and 5 deletions

View File

@ -509,7 +509,7 @@ class Client(object):
elif isinstance(destination, Object): elif isinstance(destination, Object):
return destination.id return destination.id
else: else:
raise InvalidDestination('Destination must be Channel, PrivateChannel, User, or str') raise ClientException('Destination must be Channel, PrivateChannel, User, or Object')
def on_error(self, event_method, *args, **kwargs): def on_error(self, event_method, *args, **kwargs):
print('Ignoring exception in {}'.format(event_method), file=sys.stderr) print('Ignoring exception in {}'.format(event_method), file=sys.stderr)
@ -613,6 +613,8 @@ class Client(object):
``mentions`` is ``True`` then all the users mentioned in the content are mentioned, otherwise ``mentions`` is ``True`` then all the users mentioned in the content are mentioned, otherwise
no one is mentioned. Note that to mention someone in the content, you should use :meth:`User.mention`. no one is mentioned. Note that to mention someone in the content, you should use :meth:`User.mention`.
If the destination parameter is invalid, then this function raises :class:`ClientException`.
:param destination: The location to send the message. :param destination: The location to send the message.
:param content: The content of the message to send. :param content: The content of the message to send.
:param mentions: A list of :class:`User` to mention in the message or a boolean. Ignored for private messages. :param mentions: A list of :class:`User` to mention in the message or a boolean. Ignored for private messages.

View File

@ -30,9 +30,11 @@ class DiscordException(Exception):
Ideally speaking, this could be caught to handle any exceptions thrown from this library. Ideally speaking, this could be caught to handle any exceptions thrown from this library.
""" """
class InvalidDestination(DiscordException): class ClientException(DiscordException):
"""Thrown when the destination from :meth:`Client.send_message` is invalid.""" """Exception that's thrown when an operation in the :class:`Client` fails.
pass
These are usually for exceptions that happened due to user input.
"""
class GatewayNotFound(DiscordException): class GatewayNotFound(DiscordException):
"""Thrown when the gateway hub for the :class:`Client` websocket is not found.""" """Thrown when the gateway hub for the :class:`Client` websocket is not found."""

View File

@ -284,7 +284,7 @@ The following exceptions are thrown by the library.
.. autoclass:: DiscordException .. autoclass:: DiscordException
.. autoclass:: InvalidDestination .. autoclass:: ClientException
.. autoclass:: GatewayNotFound .. autoclass:: GatewayNotFound