diff --git a/notification/src/api/notification/notification.controller.js b/notification/src/api/notification/notification.controller.js index 7446790a1..396eb6a9e 100644 --- a/notification/src/api/notification/notification.controller.js +++ b/notification/src/api/notification/notification.controller.js @@ -20,8 +20,9 @@ async function handleNotification (request, response) { 200, { 'Content-Type': 'application/json' }, JSON.stringify({ notificationResponse: '[accepted]' })) - } catch (e) { - logger.error(e, 'Unexpected exception occurred') + } catch (err) { + logger.error({ adyenRequestBody: `${body}`, err }, + 'Unexpected exception occurred.') return httpUtils.sendResponse(response, 500) } } diff --git a/notification/src/config/config.js b/notification/src/config/config.js index 7ef1b7ab5..1dca78c93 100644 --- a/notification/src/config/config.js +++ b/notification/src/config/config.js @@ -22,7 +22,7 @@ function getFileConfig () { let fileConfig = {} try { fileConfig = require(configPath) // eslint-disable-line - } catch (e) { + } catch (err) { // config file was not provided } diff --git a/notification/src/config/init/ensure-interface-interaction-custom-type.js b/notification/src/config/init/ensure-interface-interaction-custom-type.js index e87c4c67b..366ce281b 100644 --- a/notification/src/config/init/ensure-interface-interaction-custom-type.js +++ b/notification/src/config/init/ensure-interface-interaction-custom-type.js @@ -11,8 +11,8 @@ async function ensureInterfaceInteractionCustomType (ctpClient) { await ctpClient.create(ctpClient.builder.types, interfaceInteractionType) logger.info('Successfully created an interfaceInteraction type') } - } catch (e) { - logger.error(e, 'Error when creating interface interaction custom type, skipping...') + } catch (err) { + logger.error(err, 'Error when creating interface interaction custom type, skipping...') } } diff --git a/notification/src/handler/notification/notification.handler.js b/notification/src/handler/notification/notification.handler.js index 38cfc5d58..657f2f6ae 100644 --- a/notification/src/handler/notification/notification.handler.js +++ b/notification/src/handler/notification/notification.handler.js @@ -40,19 +40,19 @@ async function updatePaymentWithRepeater (payment, notification, ctpClient) { logger.debug(`Payment with interfaceId ${currentPayment.interfaceId}` + 'was successfully updated') break - } catch (e) { - if (e.body.statusCode !== 409) + } catch (err) { + if (err.body.statusCode !== 409) throw new Error(`Unexpected error during updating a payment with ID: ${currentPayment.id}. Exiting. ` - + `Error: ${JSON.stringify(serializeError(e))}`) + + `Error: ${JSON.stringify(serializeError(err))}`) retryCount += 1 if (retryCount > maxRetry) { retryMessage = 'Got a concurrent modification error' + ` when updating payment with id "${currentPayment.id}".` + ` Version tried "${currentVersion}",` - + ` currentVersion: "${e.body.errors[0].currentVersion}".` + + ` currentVersion: "${err.body.errors[0].currentVersion}".` throw new Error(`${retryMessage} Won't retry again` + ` because of a reached limit ${maxRetry}` - + ` max retries. Error: ${JSON.stringify(serializeError(e))}`) + + ` max retries. Error: ${JSON.stringify(serializeError(err))}`) } /* eslint-disable-next-line no-await-in-loop */ currentPayment = await ctpClient.fetchById(ctpClient.builder.payments, currentPayment.id) @@ -148,9 +148,9 @@ async function getPaymentByMerchantReference (merchantReference, ctpClient) { try { const result = await ctpClient.fetch(ctpClient.builder.payments.where(`interfaceId="${merchantReference}"`)) return _.get(result, 'body.results[0]', null) - } catch (e) { + } catch (err) { throw Error(`Failed to fetch a payment with merchantReference: ${merchantReference}. ` - + `Error: ${JSON.stringify(serializeError(e))}`) + + `Error: ${JSON.stringify(serializeError(err))}`) } } diff --git a/notification/src/server.js b/notification/src/server.js index 1c643438a..f1972dbad 100644 --- a/notification/src/server.js +++ b/notification/src/server.js @@ -14,8 +14,8 @@ function setupServer (routes = defaultRoutes) { if (route) try { await route(request, response) - } catch (e) { - logger.error(e, `Unexpected error when processing URL ${JSON.stringify(parts)}`) + } catch (err) { + logger.error(err, `Unexpected error when processing URL ${JSON.stringify(parts)}`) utils.sendResponse(response, 500) } else diff --git a/notification/src/utils/logger.js b/notification/src/utils/logger.js index 248178fcb..c9e186a98 100644 --- a/notification/src/utils/logger.js +++ b/notification/src/utils/logger.js @@ -9,7 +9,8 @@ function getLogger () { obj = bunyan.createLogger({ name: NOTIFICATION_MODULE_NAME, stream: process.stdout, - level: logLevel || bunyan.INFO + level: logLevel || bunyan.INFO, + serializers: bunyan.stdSerializers }) } return obj