diff --git a/aprendizations/learnapp.py b/aprendizations/learnapp.py index 51c4eda..db1037b 100644 --- a/aprendizations/learnapp.py +++ b/aprendizations/learnapp.py @@ -376,12 +376,7 @@ class LearnApp(object): for tref, attr in topics.items(): logger.debug(f' + {tref}') for d in attr.get('deps', []): - if d not in g.nodes(): - logger.error(f'Topic "{tref}" depends on "{d}" but it ' - f'does not exist') - raise LearnException() - else: - g.add_edge(d, tref) + g.add_edge(d, tref) t = g.nodes[tref] # get current topic node t['name'] = attr.get('name', tref) @@ -409,14 +404,20 @@ class LearnApp(object): # load questions as list of dicts topicpath: str = path.join(g.graph['prefix'], tref) - fullpath: str = path.join(topicpath, t['file']) + try: + fullpath: str = path.join(topicpath, t['file']) + except Exception: + msg1 = f'Invalid topic "{tref}"' + msg2 = f'Check dependencies of {", ".join(g.successors(tref))}' + raise LearnException(f'{msg1}. {msg2}') logger.debug(f' Loading {fullpath}') - # questions: List[QDict] = load_yaml(fullpath, default=[]) try: questions: List[QDict] = load_yaml(fullpath) except Exception: - raise LearnException(f'Failed to load "{fullpath}"') + msg = f'Failed to load "{fullpath}"' + logger.error(msg) + raise LearnException(msg) if not isinstance(questions, list): msg = f'File "{fullpath}" must be a list of questions' -- libgit2 0.21.2