Skip to content

Commit 6c0ade0

Browse files
authored
Update to fetch ConditionalCheckFailedException Item.
1 parent 68fc758 commit 6c0ade0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { IdempotencyRecordStatus } from '../constants';
66
import type { DynamoDBPersistenceOptions } from '../types';
77
import {
88
AttributeValue,
9+
ConditionalCheckFailedException,
910
DeleteItemCommand,
1011
DynamoDBClient,
1112
DynamoDBClientConfig,
@@ -200,15 +201,13 @@ class DynamoDBPersistenceLayer extends BasePersistenceLayer {
200201
);
201202
} catch (error) {
202203
if (error instanceof DynamoDBServiceException) {
203-
if (error.name === 'ConditionalCheckFailedException') {
204-
throw new IdempotencyItemAlreadyExistsError(
205-
`Failed to put record for already existing idempotency key: ${record.idempotencyKey}`
206-
);
207-
}
204+
if (error instanceof ConditionalCheckFailedException) {
205+
throw new IdempotencyItemAlreadyExistsError(
206+
`Failed to put record for already existing idempotency key: ${record.idempotencyKey}`,
207+
error.Item
208+
);
209+
}
208210
}
209-
210-
throw error;
211-
}
212211
}
213212

214213
protected async _updateRecord(record: IdempotencyRecord): Promise<void> {

0 commit comments

Comments
 (0)