[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:
parent
8db3435ddc
commit
1359f1000f
2 changed files with 7 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -11,14 +11,8 @@ Parameters:
|
|||
* nic.format: Format string (defaults to "{intf} {state} {ip} {ssid}")
|
||||
"""
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
import netifaces
|
||||
import subprocess
|
||||
except ImportError as e:
|
||||
log.warning("failed to import nic: {}".format(e))
|
||||
import subprocess21
|
||||
|
||||
import bumblebee.util
|
||||
import bumblebee.input
|
||||
|
|
Loading…
Reference in a new issue