i18n: Improve error logging when language JSON read fails
Before it only logged an error like this: SyntaxError: Unexpected string in JSON at position XYZ Now it also logs the filename, making it easier to figure out where the bad data is: failed to read file /path/to/etherpad-lite/src/locales/en.json: SyntaxError: Unexpected string in JSON at position XYZpull/4269/head
parent
38352c1f8c
commit
a261fdf430
|
@ -50,7 +50,13 @@ function getAllLocales() {
|
|||
locales[langcode]={};
|
||||
|
||||
files.forEach(function(file) {
|
||||
var fileContents = JSON.parse(fs.readFileSync(file,'utf8'));
|
||||
let fileContents;
|
||||
try {
|
||||
fileContents = JSON.parse(fs.readFileSync(file,'utf8'));
|
||||
} catch (err) {
|
||||
console.error(`failed to read JSON file ${file}: ${err}`);
|
||||
throw err;
|
||||
}
|
||||
_.extend(locales[langcode], fileContents);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue