Skip to content

Commit 7ed9d86

Browse files
committed
Adjust Exception names and add docs
1 parent 9104666 commit 7ed9d86

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

docs/exts/commands/exceptions.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,14 @@ Exceptions
3939

4040
.. autoexception:: twitchio.ext.commands.BadArgument
4141

42-
.. autoexception:: twitchio.ext.commands.MissingRequiredArgument
42+
.. autoexception:: twitchio.ext.commands.MissingRequiredArgument
43+
44+
.. autoexception:: twitchio.ext.commands.ModuleNotFoundError
45+
46+
.. autoexception:: twitchio.ext.commands.ModuleAlreadyLoadedError
47+
48+
.. autoexception:: twitchio.ext.commands.ModuleLoadFailure
49+
50+
.. autoexception:: twitchio.ext.commands.ModuleNotLoadedError
51+
52+
.. autoexception:: twitchio.ext.commands.NoEntryPointError

twitchio/ext/commands/bot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ async def load_module(self, name: str, *, package: str | None = None) -> None:
547547
entry = getattr(module, "setup")
548548
except AttributeError as exc:
549549
del sys.modules[name]
550-
raise NoModuleEntryPoint(f'The module "{module}" has no setup coroutine.') from exc
550+
raise NoEntryPointError(f'The module "{module}" has no setup coroutine.') from exc
551551

552552
if not asyncio.iscoroutinefunction(entry):
553553
del sys.modules[name]
@@ -595,7 +595,7 @@ async def unload_module(self, name: str, *, package: str | None = None) -> None:
595595
module = self.__modules.get(name)
596596

597597
if module is None:
598-
raise ModuleNotLoaded(name)
598+
raise ModuleNotLoadedError(name)
599599

600600
await self._remove_module_remnants(module.__name__)
601601
await self._module_finalizers(name, module)
@@ -639,7 +639,7 @@ async def reload_module(self, name: str, *, package: str | None = None) -> None:
639639
module = self.__modules.get(name)
640640

641641
if module is None:
642-
raise ModuleNotLoaded(name)
642+
raise ModuleNotLoadedError(name)
643643

644644
modules = {name: module for name, module in sys.modules.items() if _is_submodule(module.__name__, name)}
645645

twitchio/ext/commands/exceptions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
"ModuleNotFoundError",
4646
"ModuleAlreadyLoadedError",
4747
"ModuleLoadFailure",
48-
"ModuleNotLoaded",
49-
"NoModuleEntryPoint",
48+
"ModuleNotLoadedError",
49+
"NoEntryPointError",
5050
)
5151

5252

@@ -137,7 +137,7 @@ def __init__(self, exc: Exception) -> None:
137137
super().__init__(exc)
138138

139139

140-
class NoModuleEntryPoint(TwitchioException):
140+
class NoEntryPointError(TwitchioException):
141141
def __init__(self, msg: str) -> None:
142142
super().__init__(msg)
143143

@@ -147,6 +147,6 @@ def __init__(self, msg: str) -> None:
147147
super().__init__(msg)
148148

149149

150-
class ModuleNotLoaded(TwitchioException):
150+
class ModuleNotLoadedError(TwitchioException):
151151
def __init__(self, msg: str) -> None:
152152
super().__init__(msg)

0 commit comments

Comments
 (0)