Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
处理GWT呼叫失败_Gwt - Fatal编程技术网

处理GWT呼叫失败

处理GWT呼叫失败,gwt,Gwt,您好,我在GWT中有一段代码,我的一个高级同事已经编写了这段代码 public void onFailure(Throwable caught) { if (caught instanceof RuntimeException) { if (caught instanceof StatusCodeException && caught.getMessage().contains( "<tit

您好,我在GWT中有一段代码,我的一个高级同事已经编写了这段代码

public void onFailure(Throwable caught) {

    if (caught instanceof RuntimeException) {

        if (caught instanceof StatusCodeException
            && caught.getMessage().contains(
                "<title>Error 500 unAuthorized</title>")) {
            MessageBox
                .alert("Session has been expired. Press Ok to redirect to Login page.");
            History.newItem(HistoryToken.INDEX_PAGE.toString());
         } else {
        MessageBox
            .alert("An exception has occured.Press Ok to continue.");
         }

    } else if (caught instanceof InvocationException) {
        MessageBox
            .alert("Sorry... Some error occured while reaching to server.");

    }
}
public void onFailure(可丢弃捕获){
if(捕捉到RuntimeException的实例){
如果(捕获到StatusCodeException的实例)
&&捕获的.getMessage()包含(
“错误500”)){
对话框
.alert(“会话已过期。按“确定”重定向到登录页”);
newItem(HistoryToken.INDEX_PAGE.toString());
}否则{
对话框
.alert(“发生异常。请按“确定”继续”);
}
}else if(捕捉到调用异常的实例){
对话框
.alert(“对不起……在连接到服务器时发生了一些错误。”);
}
}
当服务器上的调用失败时,如果(捕获到调用异常的实例){阻塞,执行
else的机会有多大

我认为,
else if(捕获调用异常的instanceof InvocationException)
在任何情况下都不会被执行。
有什么建议吗?

因为InvocationException是RuntimeException的一个子类(如上所述),所以您是正确的


顺便问一下,你的高级同事有什么理由在getMessage上进行字符串比较,而不是用getStatusCode()检查状态代码?()

谢谢你的回复。这个家伙已经离开了公司。