def METHOD_NAME(project_id: UUID):
    try:
        yield
    # except ValidationError
    except HTTPStatusError as err:
        msg = (
            f"Failed {err.request.url} with status={err.response.status_code}: {err.response.json()}",
        )
        if codes.is_client_error(err.response.status_code):
            # client errors are mapped
            logger.debug(msg)
            if err.response.status_code == status.HTTP_404_NOT_FOUND:
                raise HTTPException(
                    status_code=status.HTTP_404_NOT_FOUND,
                    detail=f"Job {project_id} not found",
                ) from err
            raise err
        # server errors are logged and re-raised as 503
        assert codes.is_server_error(err.response.status_code)  # nosec
        logger.exception(
            "director-v2 service failed: %s. Re-rasing as service unavailable (503)",
            msg,
        )
        raise HTTPException(
            status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
            detail="Director service failed",
        ) from err