Revert "Consolidate AuthTokenExpiredError and AuthenticationError."

This reverts commit 10f7e52cff.
This commit is contained in:
Daniel Johnson 2024-05-19 16:13:35 -04:00
parent c1ea6191c8
commit 0fcffef9ed
4 changed files with 11 additions and 9 deletions

View file

@ -40,8 +40,7 @@ class MissingBiosError(GameConfigError):
class AuthenticationError(LutrisError):
"""Raised when authentication to a service fails, which may be because the user login
is not valid or has expired. We should log out and log back in response to this."""
"""Raised when authentication to a service fails"""
class UnavailableGameError(LutrisError):

View file

@ -10,7 +10,6 @@ from lutris import runners, services
from lutris.config import LutrisConfig
from lutris.database import categories as categories_db
from lutris.database import games as games_db
from lutris.exceptions import AuthenticationError
from lutris.game import GAME_START, GAME_STOPPED, GAME_UPDATED, Game
from lutris.gui.config.edit_category_games import EditCategoryGamesDialog
from lutris.gui.config.runner import RunnerConfigDialog
@ -27,6 +26,7 @@ from lutris.services.base import (
SERVICE_GAMES_LOADING,
SERVICE_LOGIN,
SERVICE_LOGOUT,
AuthTokenExpiredError,
)
from lutris.util.jobs import schedule_at_idle
from lutris.util.library_sync import LOCAL_LIBRARY_SYNCED, LOCAL_LIBRARY_SYNCING
@ -167,7 +167,7 @@ class ServiceSidebarRow(SidebarRow):
def service_reloaded_cb(self, error):
if error:
if isinstance(error, AuthenticationError):
if isinstance(error, AuthTokenExpiredError):
self.service.logout()
self.service.login(parent=self.get_toplevel()) # login will trigger reload if successful
else:

View file

@ -28,6 +28,11 @@ from lutris.util.log import logger
from lutris.util.strings import slugify
class AuthTokenExpiredError(Exception):
"""Exception raised when a token is no longer valid; the sidebar will
log-out and log-in again in response to this rather than reporting it."""
class LutrisBanner(ServiceMedia):
service = "lutris"
size = BANNER_SIZE
@ -465,8 +470,7 @@ class OnlineService(BaseService):
super().wipe_game_cache()
def logout(self):
"""Disconnect from the service by removing all credentials; may be called when
not actually logged in, in response to an AuthenticationError."""
"""Disconnect from the service by removing all credentials"""
self.wipe_game_cache()
for auth_file in self.credential_files:
try:

View file

@ -12,10 +12,9 @@ from lutris import settings
from lutris.config import LutrisConfig, write_game_config
from lutris.database.games import add_game, get_game_by_field
from lutris.database.services import ServiceGameCollection
from lutris.exceptions import AuthenticationError
from lutris.game import Game
from lutris.gui.widgets.utils import Image, paste_overlay, thumbnail_image
from lutris.services.base import SERVICE_LOGIN, OnlineService
from lutris.services.base import SERVICE_LOGIN, AuthTokenExpiredError, OnlineService
from lutris.services.lutris import sync_media
from lutris.services.service_game import ServiceGame
from lutris.services.service_media import ServiceMedia
@ -296,7 +295,7 @@ class EpicGamesStoreService(OnlineService):
library = self.get_library()
except Exception as ex: # pylint=disable:broad-except
logger.warning("EGS Token expired")
raise AuthenticationError("EGS Token expired") from ex
raise AuthTokenExpiredError("EGS Token expired") from ex
egs_games = []
for game in library:
egs_game = EGSGame.new_from_api(game)