Skip to content

Commit

Permalink
Use SyftException
Browse files Browse the repository at this point in the history
  • Loading branch information
kiendang committed Aug 27, 2024
1 parent b254e99 commit 2848e38
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/syft/src/syft/service/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions packages/syft/tests/syft/project/project_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

0 comments on commit 2848e38

Please sign in to comment.