Skip to content

Commit

Permalink
Add error handling when load tries to load non-packages
Browse files Browse the repository at this point in the history
  • Loading branch information
sravan1946 committed Oct 20, 2024
1 parent d3887b5 commit fc092b1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions redbot/core/_cog_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ async def _find_core_cog(name: str) -> ModuleSpec:

try:
mod = import_module(real_name, package=package)
if mod.__spec__.name == "redbot.cogs.locales":
raise NoSuchCog(
"No core cog by the name of '{}' could be found.".format(name),
path=mod.__spec__.origin,
name=name,
)
except ImportError as e:
if e.name == package + real_name:
raise NoSuchCog(
Expand Down

0 comments on commit fc092b1

Please sign in to comment.