Module aws_lambda_powertools.utilities.idempotency.exceptions

Idempotency errors

Expand source code
"""
Idempotency errors
"""


from typing import Optional, Union


class BaseError(Exception):
    """
    Base error class that overwrites the way exception and extra information is printed.
    See https://github.com/awslabs/aws-lambda-powertools-python/issues/1772
    """

    def __init__(self, *args: Optional[Union[str, Exception]]):
        self.message = str(args[0]) if args else ""
        self.details = "".join(str(arg) for arg in args[1:]) if args[1:] else None

    def __str__(self):
        """
        Return all arguments formatted or original message
        """
        if self.message and self.details:
            return f"{self.message} - ({self.details})"
        return self.message


class IdempotencyItemAlreadyExistsError(BaseError):
    """
    Item attempting to be inserted into persistence store already exists and is not expired
    """


class IdempotencyItemNotFoundError(BaseError):
    """
    Item does not exist in persistence store
    """


class IdempotencyAlreadyInProgressError(BaseError):
    """
    Execution with idempotency key is already in progress
    """


class IdempotencyInvalidStatusError(BaseError):
    """
    An invalid status was provided
    """


class IdempotencyValidationError(BaseError):
    """
    Payload does not match stored idempotency record
    """


class IdempotencyInconsistentStateError(BaseError):
    """
    State is inconsistent across multiple requests to persistence store
    """


class IdempotencyPersistenceLayerError(BaseError):
    """
    Unrecoverable error from the data store
    """


class IdempotencyKeyError(BaseError):
    """
    Payload does not contain an idempotent key
    """

Classes

class BaseError (*args: Union[str, Exception, None])

Base error class that overwrites the way exception and extra information is printed. See https://github.com/awslabs/aws-lambda-powertools-python/issues/1772

Expand source code
class BaseError(Exception):
    """
    Base error class that overwrites the way exception and extra information is printed.
    See https://github.com/awslabs/aws-lambda-powertools-python/issues/1772
    """

    def __init__(self, *args: Optional[Union[str, Exception]]):
        self.message = str(args[0]) if args else ""
        self.details = "".join(str(arg) for arg in args[1:]) if args[1:] else None

    def __str__(self):
        """
        Return all arguments formatted or original message
        """
        if self.message and self.details:
            return f"{self.message} - ({self.details})"
        return self.message

Ancestors

  • builtins.Exception
  • builtins.BaseException

Subclasses

class IdempotencyAlreadyInProgressError (*args: Union[str, Exception, None])

Execution with idempotency key is already in progress

Expand source code
class IdempotencyAlreadyInProgressError(BaseError):
    """
    Execution with idempotency key is already in progress
    """

Ancestors

  • BaseError
  • builtins.Exception
  • builtins.BaseException
class IdempotencyInconsistentStateError (*args: Union[str, Exception, None])

State is inconsistent across multiple requests to persistence store

Expand source code
class IdempotencyInconsistentStateError(BaseError):
    """
    State is inconsistent across multiple requests to persistence store
    """

Ancestors

  • BaseError
  • builtins.Exception
  • builtins.BaseException
class IdempotencyInvalidStatusError (*args: Union[str, Exception, None])

An invalid status was provided

Expand source code
class IdempotencyInvalidStatusError(BaseError):
    """
    An invalid status was provided
    """

Ancestors

  • BaseError
  • builtins.Exception
  • builtins.BaseException
class IdempotencyItemAlreadyExistsError (*args: Union[str, Exception, None])

Item attempting to be inserted into persistence store already exists and is not expired

Expand source code
class IdempotencyItemAlreadyExistsError(BaseError):
    """
    Item attempting to be inserted into persistence store already exists and is not expired
    """

Ancestors

  • BaseError
  • builtins.Exception
  • builtins.BaseException
class IdempotencyItemNotFoundError (*args: Union[str, Exception, None])

Item does not exist in persistence store

Expand source code
class IdempotencyItemNotFoundError(BaseError):
    """
    Item does not exist in persistence store
    """

Ancestors

  • BaseError
  • builtins.Exception
  • builtins.BaseException
class IdempotencyKeyError (*args: Union[str, Exception, None])

Payload does not contain an idempotent key

Expand source code
class IdempotencyKeyError(BaseError):
    """
    Payload does not contain an idempotent key
    """

Ancestors

  • BaseError
  • builtins.Exception
  • builtins.BaseException
class IdempotencyPersistenceLayerError (*args: Union[str, Exception, None])

Unrecoverable error from the data store

Expand source code
class IdempotencyPersistenceLayerError(BaseError):
    """
    Unrecoverable error from the data store
    """

Ancestors

  • BaseError
  • builtins.Exception
  • builtins.BaseException
class IdempotencyValidationError (*args: Union[str, Exception, None])

Payload does not match stored idempotency record

Expand source code
class IdempotencyValidationError(BaseError):
    """
    Payload does not match stored idempotency record
    """

Ancestors

  • BaseError
  • builtins.Exception
  • builtins.BaseException