build: improve logging on http errors during release process (#43759)
* build: improve logging on http errors during release process (#43756) * build: improve logging on http errors during release process (again) (#43757) * build: improve logging on http errors during release process (again, but more) (#43758)
This commit is contained in:
parent
888928887c
commit
a27df94f71
3 changed files with 37 additions and 7 deletions
|
@ -22,17 +22,27 @@ async function getAssetContents (repo, assetId) {
|
|||
const response = await got(url, {
|
||||
followRedirect: false,
|
||||
method: 'HEAD',
|
||||
headers
|
||||
headers,
|
||||
throwHttpErrors: false
|
||||
});
|
||||
|
||||
if (response.statusCode !== 302 && response.statusCode !== 301) {
|
||||
console.error('Failed to HEAD github asset contents for redirect: ' + url);
|
||||
throw new Error('Unexpected status HEAD\'ing github asset for redirect: ' + response.statusCode);
|
||||
}
|
||||
|
||||
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.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}`);
|
||||
throw new Error(`cannot download asset[${assetId}] from ${response.headers.location}, got status: ${fileResponse.statusCode}`);
|
||||
}
|
||||
|
||||
return fileResponse.body;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue