def is_transaction_expired_exception()

in pyqldb/errors/__init__.py [0:0]


def is_transaction_expired_exception(e):
    """
    Does this exception denote that a transaction has expired?

    :type e: :py:class:`builtins.Exception`
    :param e: The Exception caught.

    :rtype: bool
    :return: True if the exception denote that a transaction has expired. False otherwise.
    """
    if isinstance(e, ClientError):
        is_invalid_session = e.response['Error']['Code'] == 'InvalidSessionException'

        if "Message" in e.response["Error"]:
            return is_invalid_session and re.search("Transaction .* has expired", e.response["Error"]["Message"])
    return False