From d5431b105ad14adf7e7e5e90adaf7af00a57d3d4 Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Fri, 23 Feb 2024 22:44:30 +0100 Subject: [PATCH] Remove redundant exception --- src/main/java/fr/igred/omero/Client.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/igred/omero/Client.java b/src/main/java/fr/igred/omero/Client.java index a855a903..4e448634 100644 --- a/src/main/java/fr/igred/omero/Client.java +++ b/src/main/java/fr/igred/omero/Client.java @@ -42,6 +42,7 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; +import java.util.Objects; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; @@ -373,25 +374,22 @@ public GroupWrapper getGroup(long groupId) /** - * Returns all the groups on the OMERO database (for admins only) + * Returns all the groups on OMERO. * - * @return The list of groups on OMERO. + * @return See above. * * @throws ServiceException Cannot connect to OMERO. * @throws AccessException Cannot access data. - * @throws NoSuchElementException The requested group cannot be found. */ public List getGroups() throws ServiceException, AccessException { String error = "Cannot retrieve the groups on OMERO"; return ExceptionHandler.of(getGateway(), g -> g.getAdminService(getCtx()).lookupGroups()) - .rethrow(ApiUsageException.class, - (m, e) -> new NoSuchElementException(m), - "Groups not found") .handleOMEROException(error) .get() .stream() + .filter(Objects::nonNull) .map(GroupData::new) .map(GroupWrapper::new) .collect(Collectors.toList());