mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
add error handler to json parsing of translation files
This commit is contained in:
parent
3dbe8bfbbf
commit
8fa96c2836
@ -19,7 +19,15 @@ var Translator = (function () {
|
|||||||
xhr.open("GET", file, true);
|
xhr.open("GET", file, true);
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||||
callback(JSON.parse(xhr.responseText));
|
// needs error handler try/catch at least
|
||||||
|
let fileinfo = null;
|
||||||
|
try {
|
||||||
|
fileinfo = JSON.parse(xhr.responseText);
|
||||||
|
} catch (exception) {
|
||||||
|
// nothing here, but don't die
|
||||||
|
console.log(" loading json file failed =" + file);
|
||||||
|
}
|
||||||
|
callback(fileinfo);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.send(null);
|
xhr.send(null);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user