diff --git a/changelog/1046.feature.rst b/changelog/1046.feature.rst new file mode 100644 index 0000000000..4335e7e17d --- /dev/null +++ b/changelog/1046.feature.rst @@ -0,0 +1 @@ +|commands| Log errors raised by :meth:`.ext.commands.Cog.cog_unload`. diff --git a/disnake/ext/commands/cog.py b/disnake/ext/commands/cog.py index a0ec377d53..a0305ccea7 100644 --- a/disnake/ext/commands/cog.py +++ b/disnake/ext/commands/cog.py @@ -4,6 +4,7 @@ import asyncio import inspect +import logging from typing import ( TYPE_CHECKING, Any, @@ -48,6 +49,7 @@ FuncT = TypeVar("FuncT", bound=Callable[..., Any]) MISSING: Any = disnake.utils.MISSING +_log = logging.getLogger(__name__) def _cog_special_method(func: FuncT) -> FuncT: @@ -895,6 +897,7 @@ def _eject(self, bot: AnyBot) -> None: pass try: self.cog_unload() - except Exception: - # TODO: Consider calling the bot's on_error handler here - pass + except Exception as e: + _log.error( + "An error occurred while unloading the %s cog.", self.qualified_name, exc_info=e + )