Raise AuthenticationError from the service load() method if not authenticated.

Some services have odd errors that I don't understand, and I've just left those alone for now.
This commit is contained in:
Daniel Johnson 2024-05-19 08:37:40 -04:00
parent e2d3e6be3a
commit f4d1e1a99f
5 changed files with 10 additions and 10 deletions

View file

@ -156,8 +156,8 @@ class AmazonService(OnlineService):
def load(self):
"""Load the user game library from the Amazon API"""
if not self.is_connected():
logger.error("User not connected to Amazon")
return
raise AuthenticationError("User not connected to Amazon", self.id)
games = [AmazonGame.new_from_amazon_game(game) for game in self.get_library()]
for game in games:
game.save()

View file

@ -295,7 +295,6 @@ class EpicGamesStoreService(OnlineService):
try:
library = self.get_library()
except Exception as ex: # pylint=disable:broad-except
logger.warning("EGS Token expired")
raise AuthenticationError("EGS Token expired", self.id) from ex
egs_games = []
for game in library:

View file

@ -132,8 +132,8 @@ class GOGService(OnlineService):
def load(self):
"""Load the user game library from the GOG API"""
if not self.is_connected():
logger.error("User not connected to GOG")
return
raise AuthenticationError("User not connected to GOG", self.id)
games = [GOGGame.new_from_gog_game(game) for game in self.get_library()]
for game in games:
game.save()

View file

@ -8,7 +8,7 @@ from gettext import gettext as _
from gi.repository import Gtk
from lutris import settings
from lutris.exceptions import UnavailableGameError
from lutris.exceptions import AuthenticationError, UnavailableGameError
from lutris.gui.dialogs import HumbleBundleCookiesDialog, QuestionDialog
from lutris.installer import AUTO_ELF_EXE, AUTO_WIN32_EXE
from lutris.installer.installer_file import InstallerFile
@ -115,7 +115,9 @@ class HumbleBundleService(OnlineService):
try:
library = self.get_library()
except ValueError as ex:
raise RuntimeError("Failed to get Humble Bundle library. Try logging out and back-in.") from ex
raise AuthenticationError(
"Failed to get Humble Bundle library. Try logging out and back-in.", self.id
) from ex
humble_games = []
seen = set()
for game in library:

View file

@ -9,7 +9,7 @@ from urllib.parse import quote_plus, urlencode
from lutris import settings
from lutris.database import games as games_db
from lutris.exceptions import UnavailableGameError
from lutris.exceptions import AuthenticationError, UnavailableGameError
from lutris.installer import AUTO_ELF_EXE, AUTO_WIN32_EXE
from lutris.installer.installer_file import InstallerFile
from lutris.services.base import SERVICE_LOGIN, OnlineService
@ -144,8 +144,7 @@ class ItchIoService(OnlineService):
def load(self):
"""Load the user's itch.io library"""
if not self.is_connected():
logger.error("User not connected to itch.io")
return
raise AuthenticationError("User not connected to itch.io", self.id)
library = self.get_games()
games = []