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) => {