From 9516eaa6d72eeeabdf8dac60924fa3d5bd56d38e Mon Sep 17 00:00:00 2001 From: "Maxime Alves LIRMM@home" Date: Wed, 4 Nov 2020 17:02:19 +0100 Subject: [PATCH] RAISES when a router import fails - test your domains routers FFS --- halfapi/lib/domain.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/halfapi/lib/domain.py b/halfapi/lib/domain.py index 9431e54..942495d 100644 --- a/halfapi/lib/domain.py +++ b/halfapi/lib/domain.py @@ -136,11 +136,13 @@ def gen_router_routes(m_router: ModuleType, path: List[str]) -> Generator: subroutes = route_params.get('SUBROUTES', []) for subroute in subroutes: + logger.info('Processing subroute **%s** - %s', subroute, m_router.__name__) path.append(subroute) try: submod = importlib.import_module(f'.{subroute}', m_router.__name__) - except ImportError: - continue + except ImportError as exc: + logger.error('Failed to import subroute **{%s}**', subroute) + raise exc yield from gen_router_routes(submod, path) @@ -163,7 +165,6 @@ def gen_domain_routes(domain: str, m_dom: ModuleType) -> Generator: m_router = importlib.import_module('.routers', domain) except ImportError: logger.warning('Domain **%s** has no **routers** module', domain) - logger.debug('%s', m_dom) m_router = importlib.import_module('.routers', f'.{domain}') if m_router: