Source:
<code>public void onFailure(final Throwable caught) { if (isNotSignedIn(caught) || isInvalidXSRF(caught)) { new NotSignedInDialog().center(); } else if (isNoSuchEntity(caught)) { new ErrorDialog(Gerrit.C.notFoundBody()).center(); } else if (isInactiveAccount(caught)) { new ErrorDialog(Gerrit.C.inactiveAccountBody()).center(); } else if (isNoSuchAccount(caught)) { final String msg = caught.getMessage(); final String who = msg.substring(NoSuchAccountException.MESSAGE.length()); final ErrorDialog d = new ErrorDialog(Gerrit.M.noSuchAccountMessage(who)); d.setText(Gerrit.C.noSuchAccountTitle()); d.center(); } else if (isNameAlreadyUsed(caught)) { new ErrorDialog(Gerrit.C.nameAlreadyUsedBody()).center(); } else if (caught instanceof ServerUnavailableException) { new ErrorDialog(RpcConstants.C.errorServerUnavailable()).center(); <START> } else if (isForbiddenRefRight(caught)) { <END> final String msg = caught.getMessage(); final String allows = msg.substring(ForbiddenRefRightException.MESSAGE.length()); String err; if (allows.length() > 0) { err = Gerrit.M.forbiddenRefRight1(allows); } else { err = Gerrit.M.forbiddenRefRight2(); } final ErrorDialog d = new ErrorDialog(err); d.setText(Gerrit.C.forbidden()); d.center(); } else if (isInvalidRegExp(caught)) { final String msg = caught.getMessage(); final String regExp = msg.substring(InvalidRegExpException.MESSAGE.length()); final ErrorDialog d = new ErrorDialog(regExp); d.setText(Gerrit.C.invalidRegExp()); d.center(); } else { GWT.log(getClass().getName() + " caught " + caught, caught); new ErrorDialog(caught).center(); } }</code><technical_language>This is positioned in access editor's addRight callback. Override onError method call super if isForbiddenRefRight is true</technical_language>

Target:
public void onFailure(final Throwable caught) { if (isNotSignedIn(caught) || isInvalidXSRF(caught)) { new NotSignedInDialog().center(); } else if (isNoSuchEntity(caught)) { new ErrorDialog(Gerrit.C.notFoundBody()).center(); } else if (isInactiveAccount(caught)) { new ErrorDialog(Gerrit.C.inactiveAccountBody()).center(); } else if (isNoSuchAccount(caught)) { final String msg = caught.getMessage(); final String who = msg.substring(NoSuchAccountException.MESSAGE.length()); final ErrorDialog d = new ErrorDialog(Gerrit.M.noSuchAccountMessage(who)); d.setText(Gerrit.C.noSuchAccountTitle()); d.center(); } 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(); } else if (isRuleNotAllowed(caught)) { final String msg = caught.getMessage(); final String rule = msg.substring(RuleNotAllowedException.MESSAGE.length()); final ErrorDialog d = new ErrorDialog(Gerrit.M.ruleNotAllowedMessage(rule)); d.setText(Gerrit.C.ruleNotAllowedTitle()); } else { GWT.log(getClass().getName() + " caught " + caught, caught); new ErrorDialog(caught).center(); } }