From b44f3f4811e595b971777452aa11c099b5416648 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 24 Oct 2016 14:39:24 +0300 Subject: [PATCH] closes #5150 --- src/meta/themes.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/meta/themes.js b/src/meta/themes.js index 416b9cb00d..be48d1e70d 100644 --- a/src/meta/themes.js +++ b/src/meta/themes.js @@ -40,18 +40,21 @@ module.exports = function (Meta) { if (err) { return next(); } - - var configObj = JSON.parse(file.toString()); - - // Minor adjustments for API output - configObj.type = 'local'; - if (configObj.screenshot) { - configObj.screenshot_url = nconf.get('relative_path') + '/css/previews/' + configObj.id; - } else { - configObj.screenshot_url = nconf.get('relative_path') + '/images/themes/default.png'; + try { + var configObj = JSON.parse(file.toString()); + + // Minor adjustments for API output + configObj.type = 'local'; + if (configObj.screenshot) { + configObj.screenshot_url = nconf.get('relative_path') + '/css/previews/' + configObj.id; + } else { + configObj.screenshot_url = nconf.get('relative_path') + '/images/themes/default.png'; + } + next(null, configObj); + } catch (err) { + winston.error('[themes] Unable to parse theme.json ' + theme); + next(null, null); } - - next(null, configObj); }); }, function (err, themes) { @@ -59,9 +62,7 @@ module.exports = function (Meta) { return callback(err); } - themes = themes.filter(function (theme) { - return (theme !== undefined); - }); + themes = themes.filter(Boolean); callback(null, themes); }); });