本文整理汇总了Java中com.google.gwt.user.client.rpc.StatusCodeException类的典型用法代码示例。如果您正苦于以下问题:Java StatusCodeException类的具体用法?Java StatusCodeException怎么用?Java StatusCodeException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StatusCodeException类属于com.google.gwt.user.client.rpc包,在下文中一共展示了StatusCodeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addHashtag
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
private void addHashtag(String hashtags) {
ChangeApi.hashtags(project.get(), changeId.get())
.post(
PostInput.create(hashtags, null),
new GerritCallback<JsArrayString>() {
@Override
public void onSuccess(JsArrayString result) {
Gerrit.display(
PageLinks.toChange(project, psId.getParentKey(), String.valueOf(psId.get())));
}
@Override
public void onFailure(Throwable err) {
UIObject.setVisible(error, true);
error.setInnerText(
err instanceof StatusCodeException
? ((StatusCodeException) err).getEncodedResponse()
: err.getMessage());
hashtagTextBox.setEnabled(true);
}
});
}
示例2: onFailure
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
@Override
public void onFailure(Throwable caught) {
if (caught instanceof StatusCodeException) {
GWT.reportUncaughtException(caught);
} else {
for (Request request : this.requests) {
if (request.param.getCallbacks().isEmpty()) {
GWT.reportUncaughtException(caught);
}
for (AsyncCallback requestCallback : request.param.getCallbacks()) {
requestCallback.onFailure(caught);
}
}
if (this.callback != null) {
this.callback.onFailure(caught);
}
}
}
示例3: failureTest
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
@Test
public void failureTest() {
eventBus = new SimpleEventBus();
connectionFailedHandler = Mockito.mock(ConnectionFailedHandler.class);
dispatcher = Mockito.spy(new TestDispatcher(connectionFailedHandler, eventBus));
dispatcher.setStatusIndicator(Mockito.mock(AsyncStatusIndicator.class));
Mockito.when(connectionFailedHandler.startRecover()).thenReturn(true);
SuccessCallback<GetDescStoreResult> callback = Mockito.mock(SuccessCallback.class);
dispatcher.execute(new GetDescStore(), callback);
ArgumentCaptor<IneAsyncCallback> asyncCallbackCaptor = ArgumentCaptor
.forClass(IneAsyncCallback.class);
Mockito
.verify(dispatcher)
.doExecute(Mockito.any(Action.class), asyncCallbackCaptor.capture());
asyncCallbackCaptor.getValue().onFailure(new StatusCodeException(0, ""));
dispatcher.onEvent(new ConnectionEvent(false));
asyncCallbackCaptor.getValue().onSuccess(result);
Mockito.verify(callback).onSuccess(result);
}
示例4: onFailure
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
@Override
public void onFailure(Throwable caught) {
if (caught instanceof IncompatibleRemoteServiceException) {
ErrorReporter.reportError("App Inventor has just been upgraded, you will need to press the reload button in your browser window");
return;
}
if (caught instanceof InvalidSessionException) {
Ode.getInstance().invalidSessionDialog();
return;
}
if (caught instanceof ChecksumedFileException) {
Ode.getInstance().corruptionDialog();
return;
}
if (caught instanceof BlocksTruncatedException) {
OdeLog.log("Caught BlocksTruncatedException");
ErrorReporter.reportError("Caught BlocksTruncatedException");
return;
}
// SC_PRECONDITION_FAILED if our session has expired or login cookie
// has become invalid
if ((caught instanceof StatusCodeException) &&
((StatusCodeException)caught).getStatusCode() == Response.SC_PRECONDITION_FAILED) {
Ode.getInstance().sessionDead();
return;
}
String errorMessage =
(failureMessage == null) ? caught.getMessage() : failureMessage;
ErrorReporter.reportError(errorMessage);
OdeLog.elog("Got exception: " + caught.getMessage());
Throwable cause = caught.getCause();
if (cause != null) {
OdeLog.elog("Caused by: " + cause.getMessage());
}
}
示例5: getNonSiteExceptionMessage
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
/**
* Allows to get an exception message for the case the provided Throwable was tested to be a non SiteException.
* @param e a Throwable object that is not child of the SiteException
* @return the string corresponding to the proper error message
*/
public static String getNonSiteExceptionMessage( final Throwable e ) {
if( e instanceof StatusCodeException ) {
//In this case some of the RPC requests failed, and the exception is reported
//In principle this means that a connection to the server was lost
return I18NManager.getErrors().serverConnectionHasBeenLost();
} else {
//Just report an unknown site error
return I18NManager.getErrors().unknownInternalSiteError();
}
}
示例6: onUncaughtException
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
@Override
public void onUncaughtException(Throwable e) {
GWT.log("Unexpected exception", e);
if(e instanceof UmbrellaException) {
UmbrellaException umbrellaException = (UmbrellaException)e;
if(umbrellaException.getCause() != null) {
e = umbrellaException.getCause();
}
if(umbrellaException.getCauses() != null) {
for(Throwable cause : umbrellaException.getCauses()) {
if(cause instanceof StatusCodeException) {
e = cause;
break;
}
}
}
}
if(e instanceof StatusCodeException) {
StatusCodeException statusCodeException = (StatusCodeException)e;
if(statusCodeException.getStatusCode() == 401
|| statusCodeException.getStatusCode() == 403) {
errorLabel.setText("Unauthorized");
} else {
errorLabel.setText("HTTP status error: " + statusCodeException.getStatusCode());
}
} else {
errorLabel.setText(e.getMessage());
}
dialogBox.center();
}
示例7: getServerError
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
private String getServerError(final Throwable caught) {
String eMsg = caught != null ? caught.getMessage() : "unknown";
String msgExtra = "<span class=\"faded-text\">" +
"<br><br>If you still continue to receive this message, contact IRSA for <a href='http://irsa.ipac.caltech.edu/applications/Helpdesk' target='_blank'>help</a>. " +
"<span>";
String msg = "<b> Unable to load table.</b><br>";
if (caught instanceof StatusCodeException) {
StatusCodeException scx = (StatusCodeException) caught;
if (scx.getStatusCode() == 503) {
msg = "The site is down for scheduled maintenance.";
msgExtra = "";
} else if (scx.getStatusCode() == 0) {
msg = "If you are not connected to the internet, check your internet connection and try again";
} else {
msg = "The server encountered an unexpected condition which prevented it from fulfilling the request.<br>" +
"Refreshing the page may resolve the problem.";
}
} else if (caught instanceof RPCException) {
RPCException ex = (RPCException) caught;
if (ex.getEndUserMsg() != null) {
eMsg = ex.getEndUserMsg();
}
}
return msg + eMsg + msgExtra;
}
示例8: isNotSignedIn
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
/** True if err is describing a user that is currently anonymous. */
public static boolean isNotSignedIn(Throwable err) {
if (err instanceof StatusCodeException) {
StatusCodeException sce = (StatusCodeException) err;
if (sce.getStatusCode() == Response.SC_UNAUTHORIZED) {
return true;
}
return sce.getStatusCode() == Response.SC_FORBIDDEN
&& (sce.getEncodedResponse().equals("Authentication required")
|| sce.getEncodedResponse().startsWith("Must be signed-in")
|| sce.getEncodedResponse().startsWith("Invalid authentication"));
}
return false;
}
示例9: onError
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
@Override
public void onError(Request req, Throwable err) {
if (!background) {
RpcStatus.INSTANCE.onRpcComplete();
}
if (err.getMessage().contains("XmlHttpRequest.status")) {
cb.onFailure(
new StatusCodeException(SC_UNAVAILABLE, RpcConstants.C.errorServerUnavailable()));
} else {
cb.onFailure(new StatusCodeException(SC_BAD_TRANSPORT, err.getMessage()));
}
}
示例10: doAddKey
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
private void doAddKey() {
if (keyText.getText().isEmpty()) {
return;
}
addButton.setEnabled(false);
keyText.setEnabled(false);
AccountApi.addGpgKey(
"self",
keyText.getText(),
new AsyncCallback<NativeMap<GpgKeyInfo>>() {
@Override
public void onSuccess(NativeMap<GpgKeyInfo> result) {
keyText.setEnabled(true);
refreshKeys();
}
@Override
public void onFailure(Throwable caught) {
keyText.setEnabled(true);
addButton.setEnabled(true);
if (caught instanceof StatusCodeException) {
StatusCodeException sce = (StatusCodeException) caught;
if (sce.getStatusCode() == Response.SC_CONFLICT
|| sce.getStatusCode() == Response.SC_BAD_REQUEST) {
errorText.setText(sce.getEncodedResponse());
} else {
errorText.setText(sce.getMessage());
}
} else {
errorText.setText("Unexpected error saving key: " + caught.getMessage());
}
errorPanel.setVisible(true);
}
});
}
示例11: internalHandle
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
@Override
protected boolean internalHandle(StatusCodeException error) {
if (ErrorManager.get().hasErrorDisplayer()) {
String title = ((ServerErrorConstants) this.getConstants()).serverErrorTitle();
ErrorManager.get().getErrorDisplayer().display(title, this.getErrorMessage(error), error, Severity.DANGER);
}
return true;
}
示例12: internalHandle
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
@Override
protected boolean internalHandle(StatusCodeException error) {
if (ErrorManager.get().hasErrorDisplayer()) {
String title = ((ClientErrorConstants) this.getConstants()).clientErrorTitle();
ErrorManager.get().getErrorDisplayer().display(title, this.getErrorMessage(error), error, Severity.DANGER);
}
return true;
}
示例13: handle
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
@Override
public boolean handle(Throwable error) {
if (!(error instanceof StatusCodeException)) {
return false;
}
StatusCodeException statusCodeExc = (StatusCodeException) error;
if (this.handlesCode(statusCodeExc.getStatusCode())) {
return this.internalHandle(statusCodeExc);
}
return false;
}
示例14: getErrorMessage
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
protected String getErrorMessage(StatusCodeException exception) {
try {
return this.constants.getString(this.constantsPrefix + exception.getStatusCode());
} catch (MissingResourceException exc) {
return exception.getStatusText();
}
}
示例15: handleException
import com.google.gwt.user.client.rpc.StatusCodeException; //导入依赖的package包/类
/**
* Exception handler.
*/
public static void handleException(Throwable caught,
HasErrorMessage hasErrorMessage,
ErrorMessageCustomizer errorMessageCustomizer) {
boolean handled = false;
if (caught instanceof StatusCodeException) {
StatusCodeException sce = (StatusCodeException) caught;
if (sce.getStatusCode() == Response.SC_UNAUTHORIZED) {
onUnauthorized();
handled = true;
} else if (sce.getStatusCode() == 0) {
handleNetworkConnectionError();
handled = true;
}
} else if (caught instanceof IncompatibleRemoteServiceException) {
MessageDialog.showMessageDialog(AlertPanel.Type.ERROR, constants.incompatibleRemoteService(),
messages.incompatibleRemoteService());
handled = true;
}
if (!handled) {
String message = parseErrorMessage(caught, errorMessageCustomizer);
String[] lines = message.split("\r\n|\r|\n");
if (lines.length > 1 || (lines.length == 1 && lines[0].length() >= MAX_ERROR_LINE_LENGTH)) {
MessageDialog.showMessageDialog(AlertPanel.Type.ERROR, constants.errorTitle(), message);
} else {
hasErrorMessage.setErrorMessage(message);
}
}
}