[core/module] only log an error when a module cannot be loaded
improve logging of import errors see #606
This commit is contained in:
parent
9b63345b44
commit
bac38ece5d
1 changed files with 3 additions and 3 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
import importlib
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -19,11 +20,10 @@ def load(module_name, config=core.config.Config([]), theme=None):
|
||||||
for namespace in [ 'core', 'contrib' ]:
|
for namespace in [ 'core', 'contrib' ]:
|
||||||
try:
|
try:
|
||||||
mod = importlib.import_module('modules.{}.{}'.format(namespace, module_short))
|
mod = importlib.import_module('modules.{}.{}'.format(namespace, module_short))
|
||||||
|
log.debug('importing {} from {}.{}'.format(module_short, namespace, module_short))
|
||||||
return getattr(mod, 'Module')(config, theme)
|
return getattr(mod, 'Module')(config, theme)
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
log.fatal('failed to import {}: {}'.format(module_short, e))
|
error = e
|
||||||
if not error or module_short in error:
|
|
||||||
error = str(e)
|
|
||||||
log.fatal('failed to import {}: {}'.format(module_name, error))
|
log.fatal('failed to import {}: {}'.format(module_name, error))
|
||||||
return Error(config=config, module=module_name, error=error)
|
return Error(config=config, module=module_name, error=error)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue