From 34d8b6109b5111a09dfdca5b1b49d93dc4239b5e Mon Sep 17 00:00:00 2001 From: James Riehl Date: Mon, 11 Dec 2023 09:39:27 +0000 Subject: [PATCH 1/2] fix: catch all wallet messaging exceptions --- python/src/uagents/wallet_messaging.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/src/uagents/wallet_messaging.py b/python/src/uagents/wallet_messaging.py index 1beaffe8..107cd48d 100644 --- a/python/src/uagents/wallet_messaging.py +++ b/python/src/uagents/wallet_messaging.py @@ -60,7 +60,10 @@ def handler(*args, **kwargs): return decorator_on_message async def send(self, destination: str, msg: str, msg_type: int = 1): - self._client.send(destination, msg, msg_type) + try: + self._client.send(destination, msg, msg_type) + except Exception as ex: + self._logger.warning(f"Failed to send message to {destination}: {ex}") async def poll_server(self): self._logger.info("Connecting to wallet messaging server") @@ -72,6 +75,7 @@ async def poll_server(self): HTTPError, ConnectionError, JSONDecodeError, + Exception, ) as ex: self._logger.warning( f"Failed to get messages from wallet messaging server: {ex}" From 4baa37d0d1b7baaeeea1c65b237738c913f5fe0a Mon Sep 17 00:00:00 2001 From: James Riehl Date: Thu, 14 Dec 2023 11:32:16 +0000 Subject: [PATCH 2/2] chore: change from warning to exception --- python/src/uagents/wallet_messaging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/src/uagents/wallet_messaging.py b/python/src/uagents/wallet_messaging.py index 107cd48d..60987665 100644 --- a/python/src/uagents/wallet_messaging.py +++ b/python/src/uagents/wallet_messaging.py @@ -63,7 +63,7 @@ async def send(self, destination: str, msg: str, msg_type: int = 1): try: self._client.send(destination, msg, msg_type) except Exception as ex: - self._logger.warning(f"Failed to send message to {destination}: {ex}") + self._logger.exception(f"Failed to send message to {destination}: {ex}") async def poll_server(self): self._logger.info("Connecting to wallet messaging server")