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/aws-powertools/powertools-lambda-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
    """


class IdempotencyModelTypeError(BaseError):
    """
    Model type does not match expected payload output
    """


class IdempotencyNoSerializationModelError(BaseError):
    """
    No model was supplied to the serializer
    """

Classes

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

Base error class that overwrites the way exception and extra information is printed. See https://github.com/aws-powertools/powertools-lambda-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/aws-powertools/powertools-lambda-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, ForwardRef(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, ForwardRef(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, ForwardRef(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, ForwardRef(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, ForwardRef(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, ForwardRef(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 IdempotencyModelTypeError (*args: Union[str, Exception, ForwardRef(None)])

Model type does not match expected payload output

Expand source code
class IdempotencyModelTypeError(BaseError):
    """
    Model type does not match expected payload output
    """

Ancestors

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

No model was supplied to the serializer

Expand source code
class IdempotencyNoSerializationModelError(BaseError):
    """
    No model was supplied to the serializer
    """

Ancestors

  • BaseError
  • builtins.Exception
  • builtins.BaseException
class IdempotencyPersistenceLayerError (*args: Union[str, Exception, ForwardRef(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, ForwardRef(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