Fix error message when adding a reviewer that does not exist

If the name given for a reviewer does not match to a user the
code falls into trying to match a group. If it also does not
match a group, report that neither is found instead of saying
"Group Not Found:user@example.com".

Change-Id: I09fd4448508430faa4fdd893687f7a0def2e1141
This commit is contained in:
Shawn Pearce
2013-03-27 17:11:01 -04:00
parent b893ac82b9
commit 037551174b
3 changed files with 9 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ public class ChangeMessages extends TranslationBundle {
} }
public String revertChangeDefaultMessage; public String revertChangeDefaultMessage;
public String reviewerNotFound;
public String groupIsNotAllowed; public String groupIsNotAllowed;
public String groupHasTooManyMembers; public String groupHasTooManyMembers;

View File

@@ -129,7 +129,13 @@ public class PostReviewers implements RestModifyView<ChangeResource, Input> {
Account.Id accountId = accounts.parse(input.reviewer).getAccountId(); Account.Id accountId = accounts.parse(input.reviewer).getAccountId();
return putAccount(reviewerFactory.create(rsrc, accountId)); return putAccount(reviewerFactory.create(rsrc, accountId));
} catch (UnprocessableEntityException e) { } catch (UnprocessableEntityException e) {
return putGroup(rsrc, input); try {
return putGroup(rsrc, input);
} catch (UnprocessableEntityException e2) {
throw new UnprocessableEntityException(MessageFormat.format(
ChangeMessages.get().reviewerNotFound,
input.reviewer));
}
} }
} }

View File

@@ -1,6 +1,7 @@
# Changes to this file should also be made in # Changes to this file should also be made in
# gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeMessages.properties # gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeMessages.properties
revertChangeDefaultMessage = Revert \"{0}\"\n\nThis reverts commit {1} revertChangeDefaultMessage = Revert \"{0}\"\n\nThis reverts commit {1}
reviewerNotFound = {0} does not identify a registered user or group
groupIsNotAllowed = The group {0} cannot be added as reviewer. groupIsNotAllowed = The group {0} cannot be added as reviewer.
groupHasTooManyMembers = The group {0} has too many members to add them all as reviewers. groupHasTooManyMembers = The group {0} has too many members to add them all as reviewers.