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

Commit 066d850

Browse files
committed
Little extra logging
1 parent 44ae662 commit 066d850

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

services/CopilotPaymentService.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,12 @@ async function handlePaymentAdd(event, payment) {
183183
const accountId = await topcoderApiHelper.getProjectBillingAccountId(project.tcDirectId);
184184

185185
// use copilot id as the copilot of the challenge
186+
logger.debug(`Getting the member ID for handle: ${copilot.handle}`);
186187
const topcoderMemberId = await topcoderApiHelper.getTopcoderMemberId(copilot.handle);
187188

188189
const challengeRequirements = md.render(`$${payment.amount} - ${payment.description} `);
189190
const challengeTitle = constructChallengeName(project);
191+
190192
const newChallenge = {
191193
name: challengeTitle,
192194
projectId: project.tcDirectId,
@@ -198,6 +200,7 @@ async function handlePaymentAdd(event, payment) {
198200
copilotFee: 1
199201
};
200202

203+
logger.debug(`Creating the challenge`);
201204
// Create a new challenge
202205
const challengeId = await topcoderApiHelper.createChallenge(newChallenge);
203206

utils/topcoder-api-helper.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ async function createChallenge(challenge) {
141141
}, challenge)
142142
});
143143
try {
144+
logger.debug('Challenge body:' + challengeBody);
144145
const challengeResponse = await new Promise((resolve, reject) => {
145146
challengesApiInstance.saveDraftContest(challengeBody, (err, res) => {
146147
if (err) {
@@ -153,6 +154,7 @@ async function createChallenge(challenge) {
153154

154155
return _.get(challengeResponse, 'result.content.id');
155156
} catch (err) {
157+
logger.debug('Response:' + res);
156158
throw errors.convertTopcoderApiError(err, 'Failed to create challenge.');
157159
}
158160
}
@@ -218,7 +220,7 @@ async function activateChallenge(id) {
218220
*/
219221
async function getChallengeById(id) {
220222
if (!_.isNumber(id)) {
221-
throw new Error('The challenge id must valid number');
223+
throw new Error(`The challenge id must be a valid number, not ${id}`);
222224
}
223225
const apiKey = await getAccessToken();
224226
logger.debug('Getting topcoder challenge details');

0 commit comments

Comments
 (0)