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