mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 16:30:34 +01:00
Handle callback errors
This commit is contained in:
@@ -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) || {};
|
||||
|
||||
Reference in New Issue
Block a user