Show error messages on login screen
This commit is contained in:
@@ -46,17 +46,22 @@ class Backend:
|
||||
# Clients management
|
||||
|
||||
async def login_client(self,
|
||||
user: str,
|
||||
password: str,
|
||||
device_id: Optional[str] = None,
|
||||
homeserver: str = "https://matrix.org") -> str:
|
||||
user: str,
|
||||
password: str,
|
||||
device_id: Optional[str] = None,
|
||||
homeserver: str = "https://matrix.org",
|
||||
) -> Tuple[bool, str]:
|
||||
client = MatrixClient(
|
||||
self, user=user, homeserver=homeserver, device_id=device_id,
|
||||
)
|
||||
await client.login(password)
|
||||
try:
|
||||
await client.login(password)
|
||||
except RuntimeError as err:
|
||||
return (False, err.args[0].message)
|
||||
|
||||
self.clients[client.user_id] = client
|
||||
self.models[Account][client.user_id] = Account(client.user_id)
|
||||
return client.user_id
|
||||
return (True, client.user_id)
|
||||
|
||||
|
||||
async def resume_client(self,
|
||||
|
@@ -112,7 +112,7 @@ class MatrixClient(nio.AsyncClient):
|
||||
)
|
||||
|
||||
if isinstance(response, nio.LoginError):
|
||||
log.error(response)
|
||||
raise RuntimeError(response)
|
||||
else:
|
||||
await self.start()
|
||||
|
||||
@@ -497,7 +497,7 @@ class MatrixClient(nio.AsyncClient):
|
||||
|
||||
|
||||
async def onErrorResponse(self, resp: nio.ErrorResponse) -> None:
|
||||
# TODO: show something in the client
|
||||
# TODO: show something in the client, must be seen on login screen too
|
||||
try:
|
||||
log.warning("%s - %s", resp, json.dumps(resp.__dict__, indent=4))
|
||||
except Exception:
|
||||
|
Reference in New Issue
Block a user