from pathlib import Path


def check_file_exists(sub_dir: Path, file: Path):
    """Check if the supplied `file` arg exists.

    Args:
        sub_dir (Path): the fully qualified subdirectory
        file (Path): the file to check

    Returns:
        Path: if valid, the file

    Raises:
        Exception: if save file doesn't exist or is in the wrong place

    """

    if file.resolve().parent != sub_dir:
        file = sub_dir / file
        if not file.exists():
            raise Exception(f'{file} isn\'t in {sub_dir}')
    if file.exists():
        return file
    else:
        save_file = sub_dir / file
        if not save_file.exists():
            raise Exception(
                f"""{save_file} doesn't exist.
                Please check the filename and/or location.
                """
                )

        return save_file