Skip to content

Commit

Permalink
Raise AuthenticationError from the service load() method if not authe…
Browse files Browse the repository at this point in the history
…nticated.

Some services have odd errors that I don't understand, and I've just left those alone for now.
  • Loading branch information
danieljohnson2 committed May 19, 2024
1 parent e2d3e6b commit f4d1e1a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lutris/services/amazon.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ def is_connected(self):
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()
Expand Down
1 change: 0 additions & 1 deletion lutris/services/egs.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ def load(self):
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:
Expand Down
4 changes: 2 additions & 2 deletions lutris/services/gog.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def is_connected(self):
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()
Expand Down
6 changes: 4 additions & 2 deletions lutris/services/humblebundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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
Expand Down Expand Up @@ -115,7 +115,9 @@ def load(self):
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:
Expand Down
5 changes: 2 additions & 3 deletions lutris/services/itchio.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

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
Expand Down Expand Up @@ -144,8 +144,7 @@ def is_connected(self):
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 = []
Expand Down

0 comments on commit f4d1e1a

Please sign in to comment.