def METHOD_NAME(
    subpath: Path, path: Path, ensure_trailing_slash: bool = False
) -> str:
    """Check if 'subpath' is a subpath of 'path'
    Args:
        subpath: Subpath to be checked.
        path: Path agains which subpath is checked.
    Returns:
        'subpath', resolved, in case it is a subpath of 'path'.
    Raises:
        PackitException, if 'subpath' is not a subpath of 'path'.
    """
    try:
        subpath.resolve().relative_to(path.resolve())
    except ValueError:
        raise PackitException(
            f"Sync files: Illegal path! {subpath} is not in the subpath of {path}."
        )
    ret = str(subpath.resolve())
    if ensure_trailing_slash:
        ret += os.sep
    return ret