Skip to content

Commit 3d325a1

Browse files
committed
showing error codes on cli
1 parent 2703a20 commit 3d325a1

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

bin/commands/runs.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,16 @@ module.exports = function run(args, rawArgs) {
192192
});
193193
} else {
194194
let stacktraceUrl = getStackTraceUrl();
195-
await downloadBuildStacktrace(stacktraceUrl);
196-
logger.info(Constants.userMessages.BUILD_FAILED_ERROR)
197-
process.exitCode = Constants.BUILD_FAILED_EXIT_CODE;
195+
downloadBuildStacktrace(stacktraceUrl).then((message) => {
196+
utils.sendUsageReport(bsConfig, args, message, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
197+
}).catch((err) => {
198+
let message = `Downloading build stacktrace failed with statuscode: ${err}`;
199+
logger.error(message);
200+
utils.sendUsageReport(bsConfig, args, message, Constants.messageTypes.ERROR, null, buildReportData, rawArgs);
201+
}).finally(() =>{
202+
logger.info(Constants.userMessages.BUILD_FAILED_ERROR)
203+
process.exitCode = Constants.BUILD_FAILED_EXIT_CODE;
204+
});
198205
}
199206
});
200207
} else if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {

bin/helpers/downloadBuildStacktrace.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
'use strict'
22
const request = require('request');
33

4-
const downloadBuildStacktrace = async (url) => {
4+
const downloadBuildStacktrace = async () => {
5+
let url = "https://automate-local.bsstag.com/s3-upload/cypress-dev-staging/s3.eu-central-1/70%%20cace12bc4d920ce6d7f647f66e4a3239e291d3/session_debug.log?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA2XUQHUQMLDK6KO4W%2F20220131%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20220131T084205Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=a4ae9498d370040276dbed5fce1ed69c59db0f1809050c52baa5372e5f43e952"
56
return new Promise(async (resolve, reject) => {
6-
request.get(url).on('data', (data) => {
7-
console.log(data.toString());
8-
}).on('error', (err) => {
9-
reject();
10-
}).on('end', () => {
11-
let terminalWidth = (process.stdout.columns) * 0.9;
12-
let lineSeparator = "\n" + "-".repeat(terminalWidth);
13-
console.log(lineSeparator)
14-
resolve();
15-
})
7+
request.get(url).on('response', function (response) {
8+
if(response.statusCode == 200) {
9+
response.pipe(process.stdout);
10+
let error = null;
11+
process.stdout.on('error', (err) => {
12+
error = err;
13+
process.stdout.close();
14+
reject(err);
15+
});
16+
process.stdout.on('close', async () => {
17+
if(!error) {
18+
resolve("Build stacktrace downloaded successfully");
19+
}
20+
});
21+
} else {
22+
reject(response.statusCode);
23+
}
24+
});
1625
});
1726
};
1827

0 commit comments

Comments
 (0)