From 80c73e6c60df2d06300733f9a9d323ea149b07c9 Mon Sep 17 00:00:00 2001 From: rasswanth-s <43314053+rasswanth-s@users.noreply.github.com> Date: Sun, 15 Oct 2023 18:46:43 +0530 Subject: [PATCH] improved exception handling during connection --- .../src/syft/service/network/network_service.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/syft/src/syft/service/network/network_service.py b/packages/syft/src/syft/service/network/network_service.py index e2c32d932cd..f3367caab0c 100644 --- a/packages/syft/src/syft/service/network/network_service.py +++ b/packages/syft/src/syft/service/network/network_service.py @@ -168,8 +168,8 @@ def exchange_credentials_with( remote_node_verify_key.verify_key.verify( random_challenge, challenge_signature ) - except Exception as E: - return SyftError(message=str(E)) + except Exception as e: + return SyftError(message=str(e)) # save the remote peer for later result = self.stash.update_peer(context.node.verify_key, remote_node_peer) @@ -207,7 +207,12 @@ def add_peer( remote_client = peer.client_with_context(context=context) random_challenge = secrets.token_bytes(16) - remote_res = remote_client.api.services.network.ping(challenge=random_challenge) + try: + remote_res = remote_client.api.services.network.ping( + challenge=random_challenge + ) + except Exception as e: + return SyftError(message="Remote Peer cannot ping peer:" + str(e)) if isinstance(remote_res, SyftError): return remote_res @@ -217,8 +222,8 @@ def add_peer( # Verifying if the challenge is valid try: peer.verify_key.verify_key.verify(random_challenge, challenge_signature) - except Exception as E: - return SyftError(message=str(E)) + except Exception as e: + return SyftError(message=str(e)) result = self.stash.update_peer(context.node.verify_key, peer) if result.is_err():