diff --git a/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/route/admin/UserRoleRoute.java b/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/route/admin/UserRoleRoute.java index 8787560618..5d266b3ae3 100644 --- a/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/route/admin/UserRoleRoute.java +++ b/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/route/admin/UserRoleRoute.java @@ -102,7 +102,7 @@ protected static String handleError(Throwable e, String operation, Response resp if (e instanceof DSMBadRequestException) { response.status(400); log.info("DSMBadRequestException {}: {}", operation, e.toString()); - return e.toString(); + return e.getMessage(); } else if (e instanceof DsmInternalError) { log.error("Error {}: {}", operation, e.toString()); response.status(500); @@ -112,6 +112,6 @@ protected static String handleError(Throwable e, String operation, Response resp // any other exception log.error("Error {}: {}", operation, e.toString()); response.status(500); - return e.toString(); + return e.getMessage(); } } diff --git a/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/service/admin/UserAdminService.java b/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/service/admin/UserAdminService.java index 08dcc6a028..fcc25e7912 100644 --- a/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/service/admin/UserAdminService.java +++ b/pepper-apis/dsm-core/src/main/java/org/broadinstitute/dsm/service/admin/UserAdminService.java @@ -301,7 +301,7 @@ protected Map validateUsers(List users, int groupId) { protected void validateRoles(List roleNames, Set validRoleNames) { String msg = String.format("Invalid roles for study group %s: ", studyGroup); if (CollectionUtils.isEmpty(roleNames)) { - throw new DSMBadRequestException(msg + "None provided"); + throw new DSMBadRequestException(msg + "Users must have at least one role"); } if (validRoleNames.containsAll(roleNames)) { return; diff --git a/pepper-apis/dsm-core/src/test/java/org/broadinstitute/dsm/service/admin/UserAdminServiceTest.java b/pepper-apis/dsm-core/src/test/java/org/broadinstitute/dsm/service/admin/UserAdminServiceTest.java index 1557f3d26f..bd3b2139bc 100644 --- a/pepper-apis/dsm-core/src/test/java/org/broadinstitute/dsm/service/admin/UserAdminServiceTest.java +++ b/pepper-apis/dsm-core/src/test/java/org/broadinstitute/dsm/service/admin/UserAdminServiceTest.java @@ -238,7 +238,7 @@ public void testValidateRoles() { Assert.fail("UserAdminService.validateRoles should fail with no roles"); } catch (Exception e) { Assert.assertTrue(e.getMessage().contains("Invalid roles for study group")); - Assert.assertTrue(e.getMessage().contains("None provided")); + Assert.assertTrue(e.getMessage().contains("must have at least one role")); } try {