Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async commit(commit: Commit) {
try {
await this.dynamodb
.putItem({
TableName: this.tableName,
Item: await utils.marshallCommit(commit),
ConditionExpression: 'attribute_not_exists(v)',
ReturnValues: 'NONE',
})
.promise()
} catch (error) {
if (error.code === 'ConditionalCheckFailedException') {
throw new VersionConflictError(
`${commit.aggregateType}[${
commit.aggregateKey
}] already has a version ${commit.aggregateVersion} commit`
)
}
throw error
}
}