diff --git a/packages/idempotency/src/errors.ts b/packages/idempotency/src/errors.ts index 929b7b7090..ba2a0b77ce 100644 --- a/packages/idempotency/src/errors.ts +++ b/packages/idempotency/src/errors.ts @@ -97,8 +97,6 @@ class IdempotencyInconsistentStateError extends IdempotencyUnknownError { * Unrecoverable error from the data store */ class IdempotencyPersistenceLayerError extends IdempotencyUnknownError { - public readonly cause: Error | undefined; - public constructor(message: string, options?: ErrorOptions) { super(message, options); this.name = 'IdempotencyPersistenceLayerError'; diff --git a/packages/idempotency/tests/unit/IdempotencyHandler.test.ts b/packages/idempotency/tests/unit/IdempotencyHandler.test.ts index d9e4e0deb7..89e0f91d10 100644 --- a/packages/idempotency/tests/unit/IdempotencyHandler.test.ts +++ b/packages/idempotency/tests/unit/IdempotencyHandler.test.ts @@ -1,18 +1,18 @@ -/** - * Test Idempotency Handler - * - * @group unit/idempotency/IdempotencyHandler - */ -import { IdempotencyRecord } from '../../src/persistence/index.js'; import { IdempotencyHandler } from '../../src/IdempotencyHandler.js'; +import { IdempotencyRecordStatus, MAX_RETRIES } from '../../src/constants.js'; import { - IdempotencyConfig, IdempotencyAlreadyInProgressError, + IdempotencyConfig, IdempotencyInconsistentStateError, IdempotencyItemAlreadyExistsError, IdempotencyPersistenceLayerError, } from '../../src/index.js'; -import { MAX_RETRIES, IdempotencyRecordStatus } from '../../src/constants.js'; +/** + * Test Idempotency Handler + * + * @group unit/idempotency/IdempotencyHandler + */ +import { IdempotencyRecord } from '../../src/persistence/index.js'; import { PersistenceLayerTestClass } from '../helpers/idempotencyUtils.js'; const mockFunctionToMakeIdempotent = jest.fn(); @@ -198,12 +198,11 @@ describe('Class IdempotencyHandler', () => { .mockRejectedValue(new Error('Some error')); // Act & Assess - await expect(idempotentHandler.getFunctionResult()).rejects.toThrow( - new IdempotencyPersistenceLayerError( - 'Failed to delete record from idempotency store', - new Error('Some error') - ) - ); + await expect(idempotentHandler.getFunctionResult()).rejects.toThrow({ + name: 'IdempotencyPersistenceLayerError', + message: 'Failed to delete record from idempotency store', + cause: new Error('Some error'), + }); expect(mockDeleteInProgress).toHaveBeenCalledTimes(1); }); diff --git a/packages/idempotency/tests/unit/makeIdempotent.test.ts b/packages/idempotency/tests/unit/makeIdempotent.test.ts index 65958170cc..92da9b026c 100644 --- a/packages/idempotency/tests/unit/makeIdempotent.test.ts +++ b/packages/idempotency/tests/unit/makeIdempotent.test.ts @@ -144,6 +144,7 @@ describe('Function: makeIdempotent', () => { await expect(handler(event, context)).rejects.toThrow({ name: 'IdempotencyPersistenceLayerError', message: 'Failed to save in progress record to idempotency store', + cause: new Error('Something went wrong'), }); } ); @@ -166,6 +167,7 @@ describe('Function: makeIdempotent', () => { await expect(handler(event, context)).rejects.toThrow({ name: 'IdempotencyPersistenceLayerError', message: 'Failed to update success record to idempotency store', + cause: new Error('Something went wrong'), }); } ); @@ -186,6 +188,7 @@ describe('Function: makeIdempotent', () => { await expect(handler(event, context)).rejects.toThrow({ name: 'IdempotencyPersistenceLayerError', message: 'Failed to delete record from idempotency store', + cause: new Error('Something went wrong'), }); } );