Skip to content

Commit 8c7909a

Browse files
committed
store full error message
1 parent db4da77 commit 8c7909a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/services/PaymentSchedulerService.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async function processPayment (workPeriodPayment) {
123123
return processResult.SUCCESS
124124
} catch (err) {
125125
logger.logFullError(err, { component: 'PaymentSchedulerService', context: 'processPayment' })
126-
const statusDetails = { errorMessage: err.message, errorCode: _.get(err, 'status', -1), retry: _.get(err, 'retry', -1), step: _.get(err, 'step'), challengeId: paymentScheduler ? paymentScheduler.challengeId : null }
126+
const statusDetails = { errorMessage: extractErrorMessage(err), errorCode: _.get(err, 'status', -1), retry: _.get(err, 'retry', -1), step: _.get(err, 'step'), challengeId: paymentScheduler ? paymentScheduler.challengeId : null }
127127
const oldValue = workPeriodPayment.toJSON()
128128
// If payment processing failed Work Periods Payment "status" should be changed to "failed" and populate "statusDetails" field with error details in JSON format.
129129
const updated = await workPeriodPayment.update({ statusDetails, status: 'failed' })
@@ -332,6 +332,18 @@ async function withRetry (func, argArr, predictFunc, step) {
332332
}
333333
}
334334

335+
/**
336+
* Extract error message from throwed error object
337+
* @param {object} err the error object
338+
* @returns {String} the error message
339+
*/
340+
function extractErrorMessage (err) {
341+
return _.get(err, 'response.body.result.content.message') ||
342+
_.get(err, 'response.body.message') ||
343+
_.get(err, 'message') ||
344+
_.get(err, 'response.res.statusMessage')
345+
}
346+
335347
module.exports = {
336348
processScheduler
337349
}

0 commit comments

Comments
 (0)