Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 63e8b40

Browse files
authored
Merge pull request #61 from anonymousjaggu/logging
add tc api error fetch for create challenge
2 parents e7e26d6 + a96db73 commit 63e8b40

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

services/EventService.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async function handleEventGracefully(event, data, err) {
5050
// reschedule event
5151
if (event.retryCount < config.RETRY_COUNT) {
5252
logger.debug('Scheduling event for next retry');
53-
const newEvent = {...event};
53+
const newEvent = { ...event };
5454
newEvent.retryCount += 1;
5555
delete newEvent.copilot;
5656
const timeoutKey = setTimeout(async () => {
@@ -77,13 +77,18 @@ async function handleEventGracefully(event, data, err) {
7777
comment = `The challenge cancel failed: ${comment}`;
7878
}
7979
} else if (event.event === 'issue.created') {
80-
// comment for challenge creation failed
81-
comment = 'The challenge creation on the Topcoder platform failed. Please contact support to try again';
80+
if (err.name === 'ProcessorError' && err.statusCode && err.message) {
81+
// comment for challenge creation failed
82+
comment = `[${err.statusCode}]: ${err.message}`
83+
} else {
84+
// comment for challenge creation failed
85+
comment = 'The challenge creation on the Topcoder platform failed. Please contact support to try again';
86+
}
8287
} else if (event.event === 'copilotPayment.add') {
8388
// comment for copilot payment challenge create failed
8489
comment = 'The copilot payment challenge creation on the Topcoder platform failed. Please contact support to try again';
8590
await dbHelper.remove(models.CopilotPayment, {
86-
id: {eq: data.id}
91+
id: { eq: data.id }
8792
});
8893
// we dont need to put comment for copilot payment
8994
return;

utils/errors.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ errors.convertGitLabError = function convertGitLabError(err, message) {
7474
*/
7575
errors.convertTopcoderApiError = function convertTopcoderApiError(err, message) {
7676
let resMsg = `${message}`;
77-
const detail = _.get(err, 'response.body.result.content');
77+
const detail = _.get(err, 'response.data.message');
7878
if (detail) {
7979
resMsg += ` Detail: ${detail}`;
8080
}
8181
const apiError = new ProcessorError(
82-
err.status || _.get(err, 'response.body.result.status', constants.SERVICE_ERROR_STATUS),
83-
resMsg,
84-
'topcoder'
85-
);
82+
err.response.status || _.get(err, 'response.body.result.status', constants.SERVICE_ERROR_STATUS),
83+
resMsg,
84+
'topcoder'
85+
);
8686
return apiError;
8787
};
8888

0 commit comments

Comments
 (0)