Merge "Display proper error message if non-existing/non-visible group is browsed"

This commit is contained in:
Shawn Pearce
2011-04-07 16:48:00 -07:00
committed by Android Code Review
12 changed files with 32 additions and 8 deletions

View File

@@ -46,6 +46,8 @@ public interface GerritConstants extends Constants {
String nameAlreadyUsedBody();
String noSuchAccountTitle();
String noSuchGroupTitle();
String inactiveAccountBody();
String menuAll();

View File

@@ -29,6 +29,8 @@ notFoundBody = The page you requested was not found.
nameAlreadyUsedBody = The name is already in use.
noSuchAccountTitle = Code Review - Unknown User
noSuchGroupTitle = Code Review - Unknown Group
inactiveAccountBody = This user is currently inactive.
menuAll = All

View File

@@ -22,4 +22,6 @@ public interface GerritMessages extends Messages {
String poweredBy(String version);
String noSuchAccountMessage(String who);
String noSuchGroupMessage(String who);
}

View File

@@ -4,3 +4,5 @@ poweredBy = Powered by <a href="http://code.google.com/p/gerrit/" target="_blank
| <a href="http://code.google.com/p/gerrit/issues/list" target="_blank">Report Bug</a>
noSuchAccountMessage = {0} is not a registered user.
noSuchGroupMessage = Group {0} does not exist or is not visible to you.

View File

@@ -21,6 +21,7 @@ import com.google.gerrit.common.errors.InactiveAccountException;
import com.google.gerrit.common.errors.NameAlreadyUsedException;
import com.google.gerrit.common.errors.NoSuchAccountException;
import com.google.gerrit.common.errors.NoSuchEntityException;
import com.google.gerrit.common.errors.NoSuchGroupException;
import com.google.gerrit.common.errors.NotSignedInException;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -51,6 +52,13 @@ public abstract class GerritCallback<T> implements AsyncCallback<T> {
} else if (isNameAlreadyUsed(caught)) {
new ErrorDialog(Gerrit.C.nameAlreadyUsedBody()).center();
} else if (isNoSuchGroup(caught)) {
final String msg = caught.getMessage();
final String group = msg.substring(NoSuchGroupException.MESSAGE.length());
final ErrorDialog d = new ErrorDialog(Gerrit.M.noSuchGroupMessage(group));
d.setText(Gerrit.C.noSuchGroupTitle());
d.center();
} else if (caught instanceof ServerUnavailableException) {
new ErrorDialog(RpcConstants.C.errorServerUnavailable()).center();
@@ -89,4 +97,9 @@ public abstract class GerritCallback<T> implements AsyncCallback<T> {
return caught instanceof RemoteJsonException
&& caught.getMessage().equals(NameAlreadyUsedException.MESSAGE);
}
private static boolean isNoSuchGroup(final Throwable caught) {
return caught instanceof RemoteJsonException
&& caught.getMessage().startsWith(NoSuchGroupException.MESSAGE);
}
}