From 5bb84ce84e62bb5aa0b59a0680f4cf06a7f39977 Mon Sep 17 00:00:00 2001 From: Simon Ljungberg Date: Sat, 25 Apr 2015 22:11:10 +0200 Subject: [PATCH] fix(client): catch JSON parse errors --- assets/js/client.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/assets/js/client.js b/assets/js/client.js index c20383d..ecb11e8 100644 --- a/assets/js/client.js +++ b/assets/js/client.js @@ -314,7 +314,12 @@ fn(null, JSON.parse(this.responseText), this); } else if (this.readyState === 4 && this.status !== 200) { - fn(JSON.parse(this.responseText), null, this); + try { + fn(JSON.parse(this.responseText), null, this); + } catch (err) { + // @TODO: Handle this error. + console.log(err); + } } }; req.open(method, host);