Skip to content

Commit

Permalink
Prefer AuthenticationRequired for credential issues
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Apr 19, 2024
1 parent 53f5b5f commit 0d1c41f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions lib/galaxy/files/sources/_pyfilesystem2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
from fs.base import FS
from typing_extensions import Unpack

from galaxy.exceptions import MessageException
from galaxy.exceptions import (
AuthenticationRequired,
MessageException,
)
from . import (
BaseFilesSource,
FilesSourceOptions,
Expand Down Expand Up @@ -58,7 +61,7 @@ def _list(self, path="/", recursive=False, user_context=None, opts: Optional[Fil
to_dict = functools.partial(self._resource_info_to_dict, path)
return list(map(to_dict, res))
except fs.errors.PermissionDenied as e:
raise MessageException(
raise AuthenticationRequired(
f"Permission Denied. Reason: {e}. Please check your credentials in your preferences for {self.label}."
)
except fs.errors.FSError as e:
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/files/sources/_rdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from typing_extensions import Unpack

from galaxy.exceptions import MessageException
from galaxy.exceptions import AuthenticationRequired
from galaxy.files import ProvidesUserFileSourcesUserContext
from galaxy.files.sources import (
BaseFilesSource,
Expand Down Expand Up @@ -199,7 +199,7 @@ def get_authorization_token(self, user_context: OptionalUserContext) -> str:
effective_props = self._serialization_props(user_context)
token = effective_props.get("token")
if not token:
raise MessageException(
raise AuthenticationRequired(
f"Please provide a personal access token in your user's preferences for '{self.label}'"
)
return token
Expand Down
7 changes: 5 additions & 2 deletions lib/galaxy/files/sources/dropbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
Union,
)

from galaxy.exceptions import MessageException
from galaxy.exceptions import (
AuthenticationRequired,
MessageException,
)
from . import (
FilesSourceOptions,
FilesSourceProperties,
Expand All @@ -35,7 +38,7 @@ def _open_fs(self, user_context=None, opts: Optional[FilesSourceOptions] = None)
# This plugin might raise dropbox.dropbox_client.BadInputException
# which is not a subclass of fs.errors.FSError
if "OAuth2" in str(e):
raise MessageException(
raise AuthenticationRequired(
f"Permission Denied. Reason: {e}. Please check your credentials in your preferences for {self.label}."
)
raise MessageException(f"Error connecting to Dropbox. Reason: {e}")
Expand Down

0 comments on commit 0d1c41f

Please sign in to comment.