Skip to content

Commit 79c7041

Browse files
Handle undefined parents/children
1 parent 741734d commit 79c7041

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

plugins/output/adapt/outputHelpers.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,21 @@ function validateCourse(data, cb) {
305305

306306
function iterateThroughChildren(parents, children) {
307307
let errors = '';
308+
if (typeof parents === 'undefined') return errors;
309+
308310
parents.forEach(parent => {
309311
let parentType = app.polyglot.t('app.' + parent._type, 1);
310312
let childType = app.polyglot.t('app.children');
313+
314+
if (typeof children === 'undefined') {
315+
errors += app.polyglot.t('app.doesnotcontain', {
316+
type: parentType[0].toUpperCase() + parentType.slice(1),
317+
title: parent.title,
318+
childType: childType
319+
}) + '\n';
320+
return;
321+
}
322+
311323
if (children[0] && children[0]._type) childType = app.polyglot.t('app.' + children[0]._type, 0);
312324
let found = children.find(child => JSON.stringify(child._parentId) === JSON.stringify(parent._id));
313325

0 commit comments

Comments
 (0)