Skip to content

Node.js based forum software built for the modern web

better error handling for custom langauge files

psychobunnycf031be90412
diff --git a/src/plugins.js b/src/plugins.js
index 053f1230a7..5ca41bd353 100644
--- a/src/plugins.js
+++ b/src/plugins.js
@@ -262,8 +262,15 @@ var fs = require('fs'),
async.each(languages, function(pathToLang, next) {
fs.readFile(pathToLang, function(err, file) {
+ try {
+ var json = JSON.parse(file.toString());
+ } catch (err) {
+ winston.error('[plugins] Unable to parse custom language file: ' + pathToLang + '\r\n' + err.stack);
+ return next(err);
+ }
+
arr.push({
- file: JSON.parse(file.toString()),
+ file: json,
route: pathToLang.replace(pathToFolder, '')
});