Add try-catch to getJSON

This commit is contained in:
calzoneman 2013-03-17 20:07:18 -05:00
parent f4c044c4be
commit 173ff8c2e5
1 changed files with 6 additions and 1 deletions

View File

@ -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);
});
});