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

View File

@@ -27,7 +27,12 @@ class Item {
return this.content; 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) { updateFromJSON(json) {

View File

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