From 173ff8c2e5a785715988e1a64fdc46a8eec678a4 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sun, 17 Mar 2013 20:07:18 -0500 Subject: [PATCH] Add try-catch to getJSON --- get-info.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/get-info.js b/get-info.js index c7d37119..9fc2d45d 100644 --- a/get-info.js +++ b/get-info.js @@ -18,7 +18,12 @@ function getJSON(options, callback) { buffer += chunk; }); res.on('end', function() { - var data = JSON.parse(buffer); + try { + var data = JSON.parse(buffer); + } + catch(e) { + console.log("JSON fail"); + } callback(res.statusCode, data); }); });