Fix generic handling of NameAlreadyUsedException in GerritCallback
GerritCallback identifies a NameAlreadyUsedException by checking the
exception message. Since commit 7125a01aa2
the exception message may now include the already used name. Because of
this the check in GerritCallback must be adapted. Make sure that the
already used name is included into the displayed error message.
Change-Id: I27813bca41c6218e7f6ce740b43a8d596c8763b5
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -54,7 +54,9 @@ public abstract class GerritCallback<T> implements
|
||||
d.center();
|
||||
|
||||
} else if (isNameAlreadyUsed(caught)) {
|
||||
new ErrorDialog(Gerrit.C.nameAlreadyUsedBody()).center();
|
||||
final String msg = caught.getMessage();
|
||||
final String alreadyUsedName = msg.substring(NameAlreadyUsedException.MESSAGE.length());
|
||||
new ErrorDialog(Gerrit.M.nameAlreadyUsedBody(alreadyUsedName)).center();
|
||||
|
||||
} else if (isNoSuchGroup(caught)) {
|
||||
final String msg = caught.getMessage();
|
||||
@@ -101,7 +103,7 @@ public abstract class GerritCallback<T> implements
|
||||
|
||||
private static boolean isNameAlreadyUsed(final Throwable caught) {
|
||||
return caught instanceof RemoteJsonException
|
||||
&& caught.getMessage().equals(NameAlreadyUsedException.MESSAGE);
|
||||
&& caught.getMessage().startsWith(NameAlreadyUsedException.MESSAGE);
|
||||
}
|
||||
|
||||
private static boolean isNoSuchGroup(final Throwable caught) {
|
||||
|
||||
Reference in New Issue
Block a user