Handle callback errors

This commit is contained in:
Mathias Schreck
2016-08-16 19:46:59 +02:00
parent d43c19c173
commit ce9ee62fa0
64 changed files with 359 additions and 23 deletions

View File

@@ -30,6 +30,10 @@ Languages.get = function(code, key, callback) {
var languageData;
fs.readFile(path.join(__dirname, '../public/language/', code, key), { encoding: 'utf-8' }, function(err, data) {
if (err && err.code !== 'ENOENT') {
return callback(err);
}
// If language file in core cannot be read, then no language file present
try {
languageData = JSON.parse(data) || {};