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

Commit 5cfe9c8

Browse files
Debug user creation failure in prod
1 parent ae0078b commit 5cfe9c8

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/common/helper.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,14 @@ async function getUbahnSingleRecord (path, params, isOptionRecord) {
151151
* @returns {Promise} the created record
152152
*/
153153
async function createUbahnRecord (path, data) {
154-
const token = await getUbahnM2Mtoken()
154+
let token
155+
try {
156+
token = await getUbahnM2Mtoken()
157+
} catch (error) {
158+
logger.error('An error occurred fetching the m2m token for UBahn APIs')
159+
logger.error(error)
160+
throw error
161+
}
155162

156163
logger.debug(`request POST ${path} with data: ${JSON.stringify(data)}`)
157164
try {
@@ -189,7 +196,14 @@ async function updateUBahnRecord (path, data) {
189196
async function createUserInTopcoder (user) {
190197
const url = config.TOPCODER_USERS_API
191198
const requestBody = { param: user }
192-
const token = await getTopcoderM2Mtoken()
199+
let token
200+
try {
201+
token = await getTopcoderM2Mtoken()
202+
} catch (error) {
203+
logger.error('An error occurred fetching the m2m token for Topcoder APIs')
204+
logger.error(error)
205+
throw error
206+
}
193207

194208
logger.debug(`request POST ${url} with data: ${JSON.stringify(user)}`)
195209
try {

src/services/ProcessorService.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ async function createUserInUbahn ({ handle, firstName, lastName }) {
2424

2525
return user.id
2626
} catch (error) {
27+
logger.error('An error occurred creating the user in ubahn')
2728
logger.error(error)
2829
// Throw it to fail processing of this record
2930
throw error
@@ -62,6 +63,7 @@ async function createUserInTopcoder (user) {
6263
const newUser = await helper.createUserInTopcoder(topcoderUser)
6364
return newUser.result.content.id
6465
} catch (error) {
66+
logger.error('An error occurred creating the user in topcoder')
6567
logger.error(error)
6668
// Throw it to fail processing of this record
6769
throw error

0 commit comments

Comments
 (0)