diff --git a/src/reducers/collections.js b/src/reducers/collections.js index 118d9489..01257c4e 100644 --- a/src/reducers/collections.js +++ b/src/reducers/collections.js @@ -12,12 +12,11 @@ const collections = (state = null, action) => { case CONFIG_SUCCESS: return OrderedMap().withMutations((map) => { (configCollections || []).forEach((configCollection) => { + validateCollection(configCollection); if (has(configCollection, 'folder')) { configCollection.type = FOLDER; // eslint-disable-line no-param-reassign } else if (has(configCollection, 'files')) { configCollection.type = FILES; // eslint-disable-line no-param-reassign - } else { - throw new Error('Unknown collection type. Collections can be either Folder based or File based. Please verify your site configuration'); } map.set(configCollection.name, fromJS(configCollection)); }); @@ -27,6 +26,13 @@ const collections = (state = null, action) => { } }; +function validateCollection(configCollection) { + const collectionName = get(configCollection, 'name'); + if (!has(configCollection, 'folder') && !has(configCollection, 'files')) { + throw new Error(`Unknown collection type for collection "${ collectionName }". Collections can be either Folder based or File based.`); + } +} + const selectors = { [FOLDER]: { entryExtension(collection) {