[engine] Nicer handling of module exceptions

Do not throw exceptions during exception handling, that causes really
hard-to-interpret error messages.

Instead, log a message and throw outside the exception handler (the code
could do with some cleanup, but is localized enough for now).

see #367
This commit is contained in:
Tobias Witek 2019-03-01 21:02:51 +01:00
parent 8db3435ddc
commit 1359f1000f
2 changed files with 7 additions and 9 deletions

View file

@ -241,10 +241,14 @@ class Engine(object):
module_name = self._aliases[module_name]
if config_name is None:
config_name = module_name
err = None
try:
module = importlib.import_module("bumblebee.modules.{}".format(module_name))
except ImportError as error:
raise bumblebee.error.ModuleLoadError(error)
err = error
log.fatal("failed to import {}: {}".format(module_name, str(error)))
if err:
raise bumblebee.error.ModuleLoadError("unable to load module {}: {}".format(module_name, str(err)))
return getattr(module, "Module")(self, {
"name": config_name,
"config": self._config