[commands] Raise TypeError instead of ClientException in some places

Certain decorators and functions expect coroutines and raise an
exception when this is not met. Change these to raise the appropriate
TypeError since they can't actually be handled by the user gracefully
anyway.
This commit is contained in:
Rapptz
2019-04-07 22:31:05 -04:00
parent 84c1eac62a
commit aeabd0761e
2 changed files with 18 additions and 18 deletions

View File

@ -728,12 +728,12 @@ class Command(_BaseCommand):
Raises
-------
discord.ClientException
The coroutine is not actually a coroutine.
TypeError
The coroutine passed is not actually a coroutine.
"""
if not asyncio.iscoroutinefunction(coro):
raise discord.ClientException('The error handler must be a coroutine.')
raise TypeError('The error handler must be a coroutine.')
self.on_error = coro
return coro
@ -756,11 +756,11 @@ class Command(_BaseCommand):
Raises
-------
:exc:`.ClientException`
The coroutine is not actually a coroutine.
TypeError
The coroutine passed is not actually a coroutine.
"""
if not asyncio.iscoroutinefunction(coro):
raise discord.ClientException('The pre-invoke hook must be a coroutine.')
raise TypeError('The pre-invoke hook must be a coroutine.')
self._before_invoke = coro
return coro
@ -783,11 +783,11 @@ class Command(_BaseCommand):
Raises
-------
:exc:`.ClientException`
The coroutine is not actually a coroutine.
TypeError
The coroutine passed is not actually a coroutine.
"""
if not asyncio.iscoroutinefunction(coro):
raise discord.ClientException('The post-invoke hook must be a coroutine.')
raise TypeError('The post-invoke hook must be a coroutine.')
self._after_invoke = coro
return coro