[commands] Redesign extension exception flow.

Instead of raising a whole variety of exceptions, they are now wrapped
into ExtensionError derived classes.

* ExtensionAlreadyLoaded
	* Raised when an extension is already loaded in Bot.load_extension
* ExtensionNotLoaded
	* Raised when an extension is not loaded, e.g. Bot.unload_extension
* NoEntryPointError
	* Raised when an extension does not have a `setup` function.
* ExtensionFailed
	* Raised when an extension's `setup` function fails.
* ExtensionNotFound
	* Raised when an extension's module import fails.
This commit is contained in:
Rapptz
2019-03-19 07:35:56 -04:00
parent 26e9b5bfac
commit d9e54d7dd3
3 changed files with 140 additions and 21 deletions

View File

@ -285,6 +285,25 @@ Exceptions
.. autoexception:: discord.ext.commands.BotMissingPermissions
:members:
.. autoexception:: discord.ext.commands.ExtensionError
:members:
.. autoexception:: discord.ext.commands.ExtensionAlreadyLoaded
:members:
.. autoexception:: discord.ext.commands.ExtensionNotLoaded
:members:
.. autoexception:: discord.ext.commands.NoEntryPointError
:members:
.. autoexception:: discord.ext.commands.ExtensionFailed
:members:
.. autoexception:: discord.ext.commands.ExtensionNotFound
:members:
Exception Hierarchy
+++++++++++++++++++++
@ -311,3 +330,9 @@ Exception Hierarchy
- :exc:`~.commands.DisabledCommand`
- :exc:`~.commands.CommandInvokeError`
- :exc:`~.commands.CommandOnCooldown`
- :exc:`~.commands.ExtensionError`
- :exc:`~.commands.ExtensionAlreadyLoaded`
- :exc:`~.commands.ExtensionNotLoaded`
- :exc:`~.commands.NoEntryPointError`
- :exc:`~.commands.ExtensionFailed`
- :exc:`~.commands.ExtensionNotFound`