Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion python/src/uagents/communication.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Agent dispatch of exchange envelopes and synchronous messages."""

import asyncio
import json
import logging
import uuid
from time import time
Expand Down Expand Up @@ -146,7 +147,14 @@ async def send_exchange_envelope(
endpoint=endpoint,
session=envelope.session,
)
errors.append(await resp.text())
body = await resp.text()
try:
error_json = json.loads(body)
detail = error_json.get("detail", body)
except json.JSONDecodeError:
detail = body

errors.append(f"{resp.status}: {detail}")
except aiohttp.ClientConnectorError as ex:
errors.append(f"Failed to connect: {ex}")
except ValidationError as ex:
Expand Down
2 changes: 1 addition & 1 deletion python/src/uagents/mailbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ async def _check_mailbox_loop(self):
"Access token expired: a new one should be retrieved automatically"
)
else:
self._logger.debug(
self._logger.error(
f"Failed to retrieve messages: {resp.status}:{(await resp.text())}"
)
except ClientConnectorError as ex:
Expand Down