From 9dfee7507f354651c12ede469c7bb909cddf603b Mon Sep 17 00:00:00 2001 From: Shivang Date: Fri, 17 Dec 2021 14:51:03 +0530 Subject: [PATCH 1/3] Added actual error stack with message --- packages/sqs-partial-batch-failure/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sqs-partial-batch-failure/index.js b/packages/sqs-partial-batch-failure/index.js index 0c46bc27c..784e47725 100644 --- a/packages/sqs-partial-batch-failure/index.js +++ b/packages/sqs-partial-batch-failure/index.js @@ -87,7 +87,7 @@ const sqsPartialBatchFailureMiddleware = (opts = {}) => { const getRejectedReasons = (response) => { const rejected = response.filter((r) => r.status === 'rejected') - const rejectedReasons = rejected.map((r) => r.reason?.message) + const rejectedReasons = rejected.map((r) => `${r.reason?.message} ${r.reason?.stack}`) return rejectedReasons } From 2fcbfca9452022a239eb55d8c26d1f1e46467a74 Mon Sep 17 00:00:00 2001 From: Shivang Date: Sun, 19 Dec 2021 16:57:54 +0530 Subject: [PATCH 2/3] upgraded version --- packages/sqs-partial-batch-failure/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sqs-partial-batch-failure/package.json b/packages/sqs-partial-batch-failure/package.json index 8f427df8e..b7622c75b 100644 --- a/packages/sqs-partial-batch-failure/package.json +++ b/packages/sqs-partial-batch-failure/package.json @@ -1,6 +1,6 @@ { "name": "@middy/sqs-partial-batch-failure", - "version": "2.5.3", + "version": "2.5.4", "description": "SQS partial batch failure middleware for the middy framework", "type": "commonjs", "engines": { From 60c945361efda9a021668a253a21f7dc8d070b1e Mon Sep 17 00:00:00 2001 From: Shivang Date: Thu, 23 Dec 2021 15:14:06 +0530 Subject: [PATCH 3/3] Added original stack to error object --- packages/sqs-partial-batch-failure/index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/sqs-partial-batch-failure/index.js b/packages/sqs-partial-batch-failure/index.js index 784e47725..eb7ccbad8 100644 --- a/packages/sqs-partial-batch-failure/index.js +++ b/packages/sqs-partial-batch-failure/index.js @@ -77,7 +77,9 @@ const sqsPartialBatchFailureMiddleware = (opts = {}) => { await deleteSqsMessages(fulfilledRecords) const errorMessage = getErrorMessage(rejectedReasons) - throw new Error(errorMessage) + const error = new Error(errorMessage) + error.originalErrors = rejectedReasons + throw error } return { @@ -86,10 +88,11 @@ const sqsPartialBatchFailureMiddleware = (opts = {}) => { } const getRejectedReasons = (response) => { - const rejected = response.filter((r) => r.status === 'rejected') - const rejectedReasons = rejected.map((r) => `${r.reason?.message} ${r.reason?.stack}`) + const filteredRes = response + .filter((r) => r.status === 'rejected') + .map((r) => r.reason) - return rejectedReasons + return filteredRes } const getFulfilledRecords = (records, response) => { @@ -108,6 +111,6 @@ const getEntries = (fulfilledRecords) => { } const getErrorMessage = (rejectedReasons) => { - return rejectedReasons.join('\n') + return rejectedReasons.map(error => error.message).join('\n') } module.exports = sqsPartialBatchFailureMiddleware