SetMembersCommand: Handle REST errors gracefully
If a REST error occurs while adding a member or group to a group, the command fails with "internal server error" which is not helpful to the user. Catch REST errors and allow them to be reported back to the user. Other types of error will still result in "internal server error". Change-Id: Ia21f7aa28212f6d93ec4e6ff74a9de9ee6428a00
This commit is contained in:
@@ -20,6 +20,7 @@ import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.extensions.restapi.IdString;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
@@ -84,6 +85,7 @@ public class SetMembersCommand extends SshCommand {
|
||||
|
||||
@Override
|
||||
protected void run() throws UnloggedFailure, Failure, Exception {
|
||||
try {
|
||||
for (AccountGroup.UUID groupUuid : groups) {
|
||||
GroupResource resource =
|
||||
groupsCollection.parse(TopLevelResource.INSTANCE,
|
||||
@@ -105,6 +107,9 @@ public class SetMembersCommand extends SshCommand {
|
||||
reportGroupsAction("included to", resource, groupsToInclude);
|
||||
}
|
||||
}
|
||||
} catch (RestApiException e) {
|
||||
throw die(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void reportMembersAction(String action, GroupResource group,
|
||||
|
Reference in New Issue
Block a user