Differentiate between module "not found" and "not loaded"

This commit is contained in:
jesopo 2019-06-19 23:11:42 +01:00
parent 928f2f304d
commit 612c26ff7e

View file

@ -6,8 +6,11 @@ class ModuleException(Exception):
class ModuleWarning(Exception):
pass
class ModuleNotLoadedException(ModuleException):
pass
class ModuleNotFoundException(ModuleException):
pass
class ModuleNameCollisionException(ModuleException):
pass
class ModuleLoadException(ModuleException):
@ -310,7 +313,7 @@ class ModuleManager(object):
def unload_module(self, name: str):
if not name in self.modules:
raise ModuleNotFoundException(name)
raise ModuleNotLoadedException(name)
loaded_module = self.modules[name]
if hasattr(loaded_module.module, "unload"):
try: