core: show warning instead of exception in case of missing dependency when loading plugins
This commit is contained in:
parent
ba0e319130
commit
ae77da43fd
1 changed files with 12 additions and 5 deletions
|
|
@ -384,7 +384,7 @@ class LiberviaBackend(service.Service):
|
|||
plugin_path = f"libervia.backend.plugins.{plug_name}"
|
||||
try:
|
||||
__import__(plugin_path)
|
||||
except exceptions.MissingModule as e:
|
||||
except (ModuleNotFoundError, exceptions.MissingModule) as e:
|
||||
self._unimport_plugin(plugin_path)
|
||||
log.warning(
|
||||
"Can't import plugin [{path}] because of an unavailale third party "
|
||||
|
|
@ -503,10 +503,17 @@ class LiberviaBackend(service.Service):
|
|||
# we instanciate the plugin here
|
||||
try:
|
||||
self.plugins[import_name] = getattr(mod, plugin_info["main"])(self)
|
||||
except Exception as e:
|
||||
log.exception(
|
||||
f"Can't load plugin \"{plugin_info['name']}\", ignoring it: {e}"
|
||||
)
|
||||
except (exceptions.NotFound, Exception) as e:
|
||||
if isinstance(e, exceptions.NotFound):
|
||||
# A warning is enough for a missing dependency.
|
||||
log.warning(
|
||||
f"Can't load plugin \"{plugin_info['name']}\", due to missing "
|
||||
f"dependency, ignoring it: {e}"
|
||||
)
|
||||
else:
|
||||
log.exception(
|
||||
f"Can't load plugin \"{plugin_info['name']}\", ignoring it"
|
||||
)
|
||||
if optional:
|
||||
return
|
||||
raise ImportError("Error during initiation")
|
||||
|
|
|
|||
Loading…
Reference in a new issue