From 174aacba41cce93f9961ffd2d05dcb645765d289 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Mon, 19 Sep 2016 12:47:29 +0200 Subject: [PATCH] Don't show the status code if there's no response at all; --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index fa6bbee..e4bc9fc 100644 --- a/index.js +++ b/index.js @@ -48,7 +48,10 @@ if (config.lstu) { body = {err: 'cant parse JSON'}; } if (err || !body.success) { - console.error("Error when shortening link: (status: " + res.statusCode + ")", '\nerror:', err, '\nfailure reason:', body.msg); + console.error("Error when shortening link: ", + res ? "(status: " + res.statusCode + ")" : "(no response)", + '\nerror:', err, + '\nfailure reason:', body.msg); } else { callback(body.short); }