From f462e12b310fd1a2a92ba282cb6728fd3a4ab330 Mon Sep 17 00:00:00 2001 From: Daniel Searle Date: Mon, 14 Oct 2024 10:47:27 +0100 Subject: [PATCH] feat(CB2-14307): corect error message chack --- src/handler.ts | 2 +- tests/unit/Handler.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handler.ts b/src/handler.ts index 0ce37a4..3fcfdd8 100644 --- a/src/handler.ts +++ b/src/handler.ts @@ -39,7 +39,7 @@ const handler = async ( callback(null, 'Data processed successfully.'); } catch (error) { - if (error.body) { + if (error.message) { logger.error(JSON.stringify(error.message)); callback( null, diff --git a/tests/unit/Handler.test.ts b/tests/unit/Handler.test.ts index 4d1ef17..739d545 100644 --- a/tests/unit/Handler.test.ts +++ b/tests/unit/Handler.test.ts @@ -74,7 +74,7 @@ describe('Application entry', () => { it('should handle an error when sending the object', async () => { process.env.SEND_TO_SMC = 'True'; - const expectedErrorMessage = 'Data processed unsuccessfully: Error: Oh no!'; + const expectedErrorMessage = `Data processed unsuccessfully: ${JSON.stringify('Oh no!')}`; jest.mocked(sendMCProhibition).mockRejectedValue(new Error('Oh no!')); await handler(event, null, (error, result) => {