Show error on startup/sync failure
This commit is contained in:
parent
66b66bd27b
commit
c48952a9fa
@ -110,5 +110,7 @@ async def refresh(evt: CommandEvent) -> None:
|
||||
)
|
||||
async def sync(evt: CommandEvent) -> None:
|
||||
await evt.mark_read()
|
||||
await evt.sender.post_login(is_startup=False)
|
||||
if await evt.sender.post_login(is_startup=False):
|
||||
await evt.reply("Sync complete")
|
||||
else:
|
||||
await evt.reply("Sync failed")
|
||||
|
@ -71,6 +71,7 @@ BridgeState.human_readable_errors.update(
|
||||
"kt-reconnection-error": "Failed to reconnect to KakaoTalk",
|
||||
"kt-connection-error": "KakaoTalk disconnected unexpectedly",
|
||||
"kt-auth-error": "Authentication error from KakaoTalk: {message}",
|
||||
"kt-start-error": "Startup error from KakaoTalk: {message}",
|
||||
"kt-disconnected": None,
|
||||
"logged-out": "You're not logged into KakaoTalk",
|
||||
}
|
||||
@ -398,7 +399,7 @@ class User(DBUser, BaseUser):
|
||||
await self.save()
|
||||
return ok
|
||||
|
||||
async def post_login(self, is_startup: bool) -> None:
|
||||
async def post_login(self, is_startup: bool) -> bool:
|
||||
self.log.info("Running post-login actions")
|
||||
self._add_to_cache()
|
||||
|
||||
@ -417,6 +418,7 @@ class User(DBUser, BaseUser):
|
||||
login_result = await self.client.start()
|
||||
await self._sync_channels(login_result, is_startup)
|
||||
self.start_listen()
|
||||
return True
|
||||
except AuthenticationRequired as e:
|
||||
await self.send_bridge_notice(
|
||||
f"Got authentication error from KakaoTalk:\n\n> {e.message}\n\n",
|
||||
@ -428,7 +430,14 @@ class User(DBUser, BaseUser):
|
||||
await self.logout(remove_ktid=False)
|
||||
except Exception as e:
|
||||
self.log.exception("Failed to start client")
|
||||
await self.push_bridge_state(BridgeStateEvent.UNKNOWN_ERROR, message=str(e))
|
||||
await self.send_bridge_notice(
|
||||
f"Got error from KakaoTalk:\n\n> {e!s}\n\n",
|
||||
important=True,
|
||||
state_event=BridgeStateEvent.UNKNOWN_ERROR,
|
||||
error_code="kt-start-error",
|
||||
error_message=str(e),
|
||||
)
|
||||
return False
|
||||
|
||||
async def get_direct_chats(self) -> dict[UserID, list[RoomID]]:
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user