From ed046bcbfe9a9c8daedc89bc04debfbc9ed6b515 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 30 Aug 2023 17:05:12 +0300 Subject: [PATCH] Log errors when calling whoami for new clients --- maubot/management/api/client.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/maubot/management/api/client.py b/maubot/management/api/client.py index d95286b..2a8964c 100644 --- a/maubot/management/api/client.py +++ b/maubot/management/api/client.py @@ -16,6 +16,7 @@ from __future__ import annotations from json import JSONDecodeError +import logging from aiohttp import web @@ -27,6 +28,8 @@ from ...client import Client from .base import routes from .responses import resp +log = logging.getLogger("maubot.server.client") + @routes.get("/clients") async def get_clients(_: web.Request) -> web.Response: @@ -54,11 +57,13 @@ async def _create_client(user_id: UserID | None, data: dict) -> web.Response: ) try: whoami = await new_client.whoami() - except MatrixInvalidToken: + except MatrixInvalidToken as e: return resp.bad_client_access_token except MatrixRequestError: + log.warning(f"Failed to get whoami from {homeserver} for new client", exc_info=True) return resp.bad_client_access_details except MatrixConnectionError: + log.warning(f"Failed to connect to {homeserver} for new client", exc_info=True) return resp.bad_client_connection_details if user_id is None: existing_client = await Client.get(whoami.user_id) @@ -90,8 +95,12 @@ async def _update_client(client: Client, data: dict, is_login: bool = False) -> except MatrixInvalidToken: return resp.bad_client_access_token except MatrixRequestError: + log.warning( + f"Failed to get whoami from homeserver to update client details", exc_info=True + ) return resp.bad_client_access_details except MatrixConnectionError: + log.warning(f"Failed to connect to homeserver to update client details", exc_info=True) return resp.bad_client_connection_details except ValueError as e: str_err = str(e)