Throw an exception when a referenced group is not found

Change-Id: Id3c61dcf70492ba05475df4656fd89bad40c9324
This commit is contained in:
Alice Kober-Sotzek
2017-07-28 18:30:10 +02:00
parent 04a2720fb6
commit 4a0057373d
21 changed files with 184 additions and 178 deletions

View File

@@ -20,6 +20,7 @@ import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.common.data.GroupDescriptions;
import com.google.gerrit.common.errors.InvalidSshKeyException;
import com.google.gerrit.common.errors.NoSuchGroupException;
import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.api.accounts.AccountInput;
import com.google.gerrit.extensions.common.AccountInfo;
@@ -186,7 +187,11 @@ public class CreateAccount implements RestModifyView<TopLevelResource, AccountIn
});
for (AccountGroup.UUID groupUuid : groups) {
groupsUpdate.get().addGroupMember(db, groupUuid, id);
try {
groupsUpdate.get().addGroupMember(db, groupUuid, id);
} catch (NoSuchGroupException e) {
throw new UnprocessableEntityException(String.format("Group %s not found", groupUuid));
}
}
if (input.sshKey != null) {