improve error messages when attached modules fail on startup
Change-Id: Ic1d2d77de2574043749ddbc00def48a6fe77b2bd
This commit is contained in:
@@ -30,6 +30,10 @@ from frappy.version import get_version
|
||||
from frappy.modules import Module
|
||||
|
||||
|
||||
class InitFailed(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class SecNode:
|
||||
"""Managing the modules.
|
||||
|
||||
@@ -85,11 +89,15 @@ class SecNode:
|
||||
if not modobj.initModuleDone:
|
||||
self.errors.append(f'{modobj.initModule.__qualname__} was not '
|
||||
f'called, probably missing super call')
|
||||
except InitFailed:
|
||||
raise
|
||||
except Exception as e:
|
||||
if self.traceback_counter == 0:
|
||||
self.log.exception(traceback.format_exc())
|
||||
self.traceback_counter += 1
|
||||
self.errors.append(f'error initializing {modulename}: {e!r}')
|
||||
modobj._initfailed = True
|
||||
raise InitFailed('try to access erroneous module')
|
||||
modobj._isinitialized = True
|
||||
self.log.debug('initialized module %r', modulename)
|
||||
return modobj
|
||||
@@ -101,8 +109,11 @@ class SecNode:
|
||||
When creating a new module, srv.module_config is accessed to get the
|
||||
modules configuration.
|
||||
"""
|
||||
if modulename in self.modules:
|
||||
return self.modules[modulename]
|
||||
modobj = self.modules.get(modulename)
|
||||
if modobj:
|
||||
if modobj._initfailed:
|
||||
raise InitFailed('try to access erroneous module')
|
||||
return modobj
|
||||
if modulename in list(self.modules.values()):
|
||||
# it's actually already the module object
|
||||
return modulename
|
||||
@@ -205,8 +216,11 @@ class SecNode:
|
||||
def build_descriptive_data(self):
|
||||
modules = {}
|
||||
result = {'modules': modules}
|
||||
for modulename in self.modules:
|
||||
modobj = self.get_module(modulename)
|
||||
for modulename in list(self.modules):
|
||||
try:
|
||||
modobj = self.get_module(modulename)
|
||||
except InitFailed:
|
||||
continue
|
||||
if not modobj.export:
|
||||
continue
|
||||
# some of these need rework !
|
||||
|
||||
Reference in New Issue
Block a user