json parse exception handling

This commit is contained in:
Mo Bitar
2017-01-15 18:10:10 -06:00
parent 32b709c689
commit bbedad0fc5
3 changed files with 8 additions and 5 deletions

View File

@@ -7,12 +7,10 @@ var Neeto = Neeto || {};
var IEOrEdge = document.documentMode || /Edge/.test(navigator.userAgent);
if(!IEOrEdge && (window.crypto && window.crypto.subtle)) {
console.log("Using webcrypto");
Neeto.crypto = new SNCryptoWeb();
} else {
console.log("Using CryptoJS");
Neeto.crypto = new SNCryptoJS();
}
Neeto.crypto = new SNCryptoJS();
angular.module('app.frontend', [
'ui.router',

View File

@@ -27,7 +27,12 @@ class Item {
return this.content;
}
return JSON.parse(this.content);
try {
return JSON.parse(this.content);
} catch (e) {
console.log("Error parsing json", e);
return {};
}
}
updateFromJSON(json) {

View File

@@ -566,7 +566,7 @@ angular.module('app.frontend')
item.content = Neeto.crypto.base64Decode(item.content.substring(3, item.content.length))
}
} catch (e) {
console.log("Error decrypting item", item);
console.log("Error decrypting item", item, e);
continue;
}
}