UNPKG

@aws-lambda-powertools/idempotency

Version:

The idempotency package for the Powertools for AWS Lambda (TypeScript) library. It provides options to make your Lambda functions idempotent and safe to retry.

100 lines (99 loc) 3.3 kB
/** * Base error for idempotency errors. * * Generally this error should not be thrown directly unless you are throwing a generic and unknown error. */ class IdempotencyUnknownError extends Error { constructor(message, options) { super(message, options); this.name = 'IdempotencyUnknownError'; } } /** * Item attempting to be inserted into persistence store already exists and is not expired */ class IdempotencyItemAlreadyExistsError extends IdempotencyUnknownError { existingRecord; constructor(message, existingRecord, options) { super(message, options); this.name = 'IdempotencyItemAlreadyExistsError'; this.existingRecord = existingRecord; } } /** * Item does not exist in persistence store */ class IdempotencyItemNotFoundError extends IdempotencyUnknownError { constructor(message, options) { super(message, options); this.name = 'IdempotencyItemNotFoundError'; } } /** * Execution with idempotency key is already in progress */ class IdempotencyAlreadyInProgressError extends IdempotencyUnknownError { existingRecord; constructor(message, existingRecord, options) { super(message, options); this.name = 'IdempotencyAlreadyInProgressError'; this.existingRecord = existingRecord; } } /** * An invalid status was provided */ class IdempotencyInvalidStatusError extends IdempotencyUnknownError { constructor(message, options) { super(message, options); this.name = 'IdempotencyInvalidStatusError'; } } /** * Payload does not match stored idempotency record */ class IdempotencyValidationError extends IdempotencyUnknownError { existingRecord; constructor(message, existingRecord, options) { super(message, options); this.name = 'IdempotencyValidationError'; this.existingRecord = existingRecord; } } /** * State is inconsistent across multiple requests to persistence store */ class IdempotencyInconsistentStateError extends IdempotencyUnknownError { constructor(message, options) { super(message, options); this.name = 'IdempotencyInconsistentStateError'; } } /** * Unrecoverable error from the data store */ class IdempotencyPersistenceLayerError extends IdempotencyUnknownError { constructor(message, options) { super(message, options); this.name = 'IdempotencyPersistenceLayerError'; } } /** * Payload does not contain an idempotent key */ class IdempotencyKeyError extends IdempotencyUnknownError { constructor(message, options) { super(message, options); this.name = 'IdempotencyKeyError'; } } /** * Error with the persistence layer's consistency, needs to be removed */ class IdempotencyPersistenceConsistencyError extends IdempotencyUnknownError { constructor(message, options) { super(message, options); this.name = 'IdempotencyPersistenceConsistencyError'; } } export { IdempotencyUnknownError, IdempotencyItemAlreadyExistsError, IdempotencyItemNotFoundError, IdempotencyAlreadyInProgressError, IdempotencyInvalidStatusError, IdempotencyValidationError, IdempotencyInconsistentStateError, IdempotencyPersistenceLayerError, IdempotencyPersistenceConsistencyError, IdempotencyKeyError, };