Skip to content

Commit d267eb5

Browse files
roshan04Karan Nagpal
authored andcommitted
handle promises errors
1 parent 950142c commit d267eb5

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

bin/helpers/buildArtifacts.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,10 @@ const downloadAndUnzip = async (filePath, fileName, url) => {
9999
let tmpFilePath = path.join(filePath, fileName);
100100
const writer = fs.createWriteStream(tmpFilePath);
101101

102-
console.log(`roshan1: url ${url}`)
103-
console.log(`roshan inside downloadAndUnzip`)
104-
return request.get(url).on('response', function(response) {
105-
//ensure that the user can call `then()` only when the file has
106-
//been downloaded entirely.
107-
console.log(`roshan1: response ${inspect(response)}`)
108-
return new Promise(async (resolve, reject) => {
102+
return new Promise(async (resolve, reject) => {
103+
request.get(url).on('response', function(response) {
104+
//ensure that the user can call `then()` only when the file has
105+
//been downloaded entirely.
109106
response.pipe(writer);
110107
let error = null;
111108
writer.on('error', err => {
@@ -183,7 +180,6 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs) =>
183180
}
184181

185182
exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
186-
console.log('hello brother')
187183
BUILD_ARTIFACTS_FAIL_COUNT = 0;
188184
BUILD_ARTIFACTS_TOTAL_COUNT = 0;
189185

@@ -219,7 +215,6 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
219215
} else {
220216
await createDirectories(buildId, buildDetails);
221217
await parseAndDownloadArtifacts(buildId, buildDetails);
222-
console.log(`roshan1 making request passed1 ${inspect(buildDetails)}`);
223218
if (BUILD_ARTIFACTS_FAIL_COUNT > 0) {
224219
messageType = Constants.messageTypes.ERROR;
225220
message = Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_FAILED.replace('<build-id>', buildId).replace('<machine-count>', BUILD_ARTIFACTS_FAIL_COUNT);
@@ -251,7 +246,6 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
251246
}
252247
});
253248
} catch (err) {
254-
console.log(`roshan1: error here ${err}`)
255249
utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'api_failed_build_artifacts', null, rawArgs);
256250
process.exitCode = Constants.ERROR_EXIT_CODE;
257251
}

0 commit comments

Comments
 (0)