From 9c22fbc462b989b105ccab981eee5ac8c9d7556a Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sun, 11 Aug 2013 17:44:48 -0400 Subject: [PATCH] Add try-catch to urlRetrieve to prevent uncaught HTTPS exceptions --- get-info.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/get-info.js b/get-info.js index 24ef4071..c545926d 100644 --- a/get-info.js +++ b/get-info.js @@ -17,18 +17,22 @@ var CustomEmbedFilter = require("./customembed").filter; module.exports = function (Server) { function urlRetrieve(transport, options, callback) { - var req = transport.request(options, function (res) { - var buffer = ""; - res.setEncoding("utf-8"); - res.on("data", function (chunk) { - buffer += chunk; + try { + var req = transport.request(options, function (res) { + var buffer = ""; + res.setEncoding("utf-8"); + res.on("data", function (chunk) { + buffer += chunk; + }); + res.on("end", function () { + callback(res.statusCode, buffer); + }); }); - res.on("end", function () { - callback(res.statusCode, buffer); - }); - }); - req.end(); + req.end(); + } catch(e) { + callback(503, ""); + } } var Getters = {