def METHOD_NAME(cls, function=None):
    """
    Should only be called by py:`LockableDatabase.transaction`.
    Find the caller of and construct an exception referencing it. This will
    skip over the wrapper from :py:`with_cursor`.
    This must be called on a subclass that defines `.message`.
    """
    # There are 2 stack frames between this function
    # 0. _LockableDatabaseTransactionError.from_stack
    # 1. LockableDatabase.transaction
    # 2. contextlib.contextmanger's __enter__
    # 3. Our caller (potentially with_cursor)
    frame = currentframe(3)
    if frame.f_code == with_cursor._wrapped_code:
        frame = frame.f_back
    caller = frame.f_code.co_name
    return cls(caller=caller, function=function)