Don't show the status code if there's no response at all;

This commit is contained in:
Benjamin Bouvier 2016-09-19 12:47:29 +02:00
parent 84c2b37469
commit 174aacba41

View File

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