build: improve logging on http errors during release process (#43756)
This commit is contained in:
parent
233724fe00
commit
10ba87a85e
3 changed files with 41 additions and 6 deletions
|
@ -22,14 +22,29 @@ async function getAssetContents (repo, assetId) {
|
|||
const response = await got(url, {
|
||||
followRedirect: false,
|
||||
method: 'HEAD',
|
||||
headers
|
||||
headers,
|
||||
throwHttpErrors: false
|
||||
});
|
||||
|
||||
if (response.status !== 302 && response.status !== 301) {
|
||||
console.error('Failed to HEAD github asset contents for redirect: ' + url);
|
||||
throw new Error('Unexpected status HEAD\'ing github asset: ' + response.status);
|
||||
}
|
||||
|
||||
if (!response.headers.location) {
|
||||
console.error(response.headers, `${response.body}`.slice(0, 300));
|
||||
throw new Error(`cannot find asset[${assetId}], asset download did not redirect`);
|
||||
}
|
||||
|
||||
const fileResponse = await got(response.headers.location);
|
||||
const fileResponse = await got(response.headers.location, {
|
||||
throwHttpErrors: false
|
||||
});
|
||||
|
||||
if (fileResponse.status !== 200) {
|
||||
fileResponse.error(`Failed to download github asset contents: ${url} (via: ${response.headers.location})`);
|
||||
throw new Error('Unexpected status fetching github asset: ' + fileResponse.status);
|
||||
}
|
||||
|
||||
if (fileResponse.statusCode !== 200) {
|
||||
console.error(fileResponse.headers, `${fileResponse.body}`.slice(0, 300));
|
||||
throw new Error(`cannot download asset[${assetId}] from ${response.headers.location}, got status: ${fileResponse.status}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue