def array_current_index(array):
    """
    Return the current index (elementIndex()) of a MArrayDataHandle, or -1 if the
    current index isn't valid, probably because the array is empty.
    """
    try:
        return array.elementIndex()
    except RuntimeError as e:
        # If the array is empty, elementIndex raises an error.
        return -1