Skip to content

Commit

Permalink
Raise errors instead of returning messages
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Dec 2, 2023
1 parent 9df3f5a commit 523c9be
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/galaxy/managers/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def purge(self, trans: ProvidesUserContext, role: model.Role) -> model.Role:
# - GroupRoleAssociations where role_id == Role.id
# - DatasetPermissionss where role_id == Role.id
if not role.deleted:
return (f"Role '{role.name}' has not been deleted, so it cannot be purged.", "error")
raise galaxy.exceptions.RequestParameterInvalidException(
f"Role '{role.name}' has not been deleted, so it cannot be purged."
)
# Delete UserRoleAssociations
for ura in role.users:
user = trans.sa_session.query(trans.app.model.User).get(ura.user_id)
Expand All @@ -143,7 +145,9 @@ def purge(self, trans: ProvidesUserContext, role: model.Role) -> model.Role:

def undelete(self, trans: ProvidesUserContext, role: model.Role) -> model.Role:
if not role.deleted:
return (f"Role '{role.name}' has not been deleted, so it cannot be undeleted.", "error")
raise galaxy.exceptions.RequestParameterInvalidException(
f"Role '{role.name}' has not been deleted, so it cannot be undeleted."
)
role.deleted = False
trans.sa_session.add(role)
with transaction(trans.sa_session):
Expand Down

0 comments on commit 523c9be

Please sign in to comment.