mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-22 02:37:57 -05:00
[Core] Support already loaded packages in [p]load (#2116)
This commit is contained in:
committed by
Toby Harradine
parent
ee7e8aa782
commit
76bbcf2f8c
16
redbot/core/errors.py
Normal file
16
redbot/core/errors.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import importlib.machinery
|
||||
|
||||
|
||||
class RedError(Exception):
|
||||
"""Base error class for Red-related errors."""
|
||||
|
||||
|
||||
class PackageAlreadyLoaded(RedError):
|
||||
"""Raised when trying to load an already-loaded package."""
|
||||
|
||||
def __init__(self, spec: importlib.machinery.ModuleSpec, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.spec: importlib.machinery.ModuleSpec = spec
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"There is already a package named {self.spec.name.split('.')[-1]} loaded"
|
||||
Reference in New Issue
Block a user