Skip to content

Commit

Permalink
improved exception handling during connection
Browse files Browse the repository at this point in the history
  • Loading branch information
rasswanth-s committed Oct 15, 2023
1 parent 1181461 commit 80c73e6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/syft/src/syft/service/network/network_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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():
Expand Down

0 comments on commit 80c73e6

Please sign in to comment.