Fix expected response when there's a socket error (#3597)

In the case of a network issue, there's an error but no response, so no statusCode, This fixes it

Fixes #3594
This commit is contained in:
Francis Levasseur
2021-01-29 14:10:38 -05:00
committed by GitHub
parent 3c23217358
commit 63c1827c63

View File

@@ -27,8 +27,8 @@ UrlFileManager.prototype = Object.assign(new AbstractFileManager(), {
const hackUrlStr = urlStr.indexOf('?') === -1 ? urlStr + '?' : urlStr
request.get(hackUrlStr, { follow_max: 5 }, (err, resp, body) => {
if (err || resp.statusCode >= 400) {
const message = resp.statusCode === 404
if (err || resp && resp.statusCode >= 400) {
const message = resp && resp.statusCode === 404
? `resource '${urlStr}' was not found\n`
: `resource '${urlStr}' gave this Error:\n ${err || resp.statusMessage || resp.statusCode}\n`;
reject({ type: 'File', message });