More readable errors for failed registry requests

This commit is contained in:
Michael Jackson 2018-07-15 09:56:51 -07:00
parent d1a6db5747
commit d05ff65089
2 changed files with 3 additions and 2 deletions

View File

@ -25,7 +25,8 @@ function fetchNpmPackage(packageConfig) {
if (res.statusCode === 200) {
resolve(res.pipe(gunzip()).pipe(tar.extract()));
} else {
reject(res);
const spec = `${packageConfig.name}@${packageConfig.version}`;
reject(new Error(`Failed to fetch tarball for ${spec}`));
}
})
.on("error", reject);

View File

@ -37,7 +37,7 @@ function fetchNpmPackageInfo(packageName) {
if (res.statusCode === 200) {
resolve(parseJSON(res));
} else {
reject(res);
reject(new Error(`Failed to fetch info for ${packageName}`));
}
})
.on("error", reject);