🐛 Fix the exception caused by account ID not found

This commit is contained in:
洛水居室 2023-03-15 16:04:13 +08:00
parent 1525d7cafd
commit e086f011a1
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC

View File

@ -94,6 +94,8 @@ class PublicCookiesService(BaseService):
else: else:
raise CookieServiceError raise CookieServiceError
try: try:
if client.cookie_manager.user_id is None:
raise RuntimeError("account_id not found")
record_card = (await client.get_record_cards())[0] record_card = (await client.get_record_cards())[0]
if record_card.game == Game.GENSHIN and region == RegionEnum.HYPERION: if record_card.game == Game.GENSHIN and region == RegionEnum.HYPERION:
await client.get_partial_genshin_user(record_card.uid) await client.get_partial_genshin_user(record_card.uid)
@ -123,6 +125,14 @@ class PublicCookiesService(BaseService):
logger.exception(exc) logger.exception(exc)
await self._cache.delete_public_cookies(cookies.user_id, region) await self._cache.delete_public_cookies(cookies.user_id, region)
continue continue
except RuntimeError as exc:
if "account_id not found" in str(exc):
cookies.status = CookiesStatusEnum.INVALID_COOKIES
await self._repository.update(cookies)
await self._cache.delete_public_cookies(cookies.user_id, region)
continue
else:
raise exc
except Exception as exc: except Exception as exc:
await self._cache.delete_public_cookies(cookies.user_id, region) await self._cache.delete_public_cookies(cookies.user_id, region)
raise exc raise exc