From 2848e38da951b89c94ab628909b4eb8a91075d22 Mon Sep 17 00:00:00 2001 From: Kien Dang Date: Tue, 27 Aug 2024 16:24:34 +0800 Subject: [PATCH] Use SyftException --- packages/syft/src/syft/service/project/project.py | 2 +- packages/syft/tests/syft/project/project_test.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/syft/src/syft/service/project/project.py b/packages/syft/src/syft/service/project/project.py index 406a2d7508e..540ae586152 100644 --- a/packages/syft/src/syft/service/project/project.py +++ b/packages/syft/src/syft/service/project/project.py @@ -1236,7 +1236,7 @@ def start(self, return_all_projects: bool = False) -> Project | list[Project]: def send(self, return_all_projects: bool = False) -> Project | list[Project]: if len(self.clients) == 0: - return SyftError(message=_EMPTY_MEMBER_LIST_ERROR_MESSAGE) + raise SyftException(public_message=_EMPTY_MEMBER_LIST_ERROR_MESSAGE) # Currently we are assuming that the first member is the leader # This would be changed in our future leaderless approach diff --git a/packages/syft/tests/syft/project/project_test.py b/packages/syft/tests/syft/project/project_test.py index abb18921a19..797583ad522 100644 --- a/packages/syft/tests/syft/project/project_test.py +++ b/packages/syft/tests/syft/project/project_test.py @@ -6,7 +6,7 @@ import syft as sy from syft.service.project.project import Project from syft.service.project.project import _EMPTY_MEMBER_LIST_ERROR_MESSAGE -from syft.service.response import SyftError +from syft.types.errors import SyftException def test_project_creation(worker): @@ -119,6 +119,6 @@ def test_submit_project_with_empty_member_list_error() -> None: name="My Cool Project", description="My Cool Description", members=[] ) - res = new_project.send() - assert isinstance(res, SyftError) - assert _EMPTY_MEMBER_LIST_ERROR_MESSAGE in res.message + with pytest.raises(SyftException) as exc: + new_project.send() + assert _EMPTY_MEMBER_LIST_ERROR_MESSAGE in exc.value.public_message