2012-07-12 53 views
0

我执行我的异步函数,并在结果之前我重新加载浏览器我得到错误 - OnFailure(Throwable)执行。状态错误代码为0.异步功能 - 错误状态0

此问题出现在FireFox和Chrome上。

你能告诉我这个状态码的含义吗?

do(new AsyncCallback<Boolean>() { 
    @Override 
    public void onSuccess(Boolean result) {} 

    @Override 
    public void onFailure(Throwable throw) { 
     do_sth(); 
    } 
}); 

Boolean do() { while(true); } 

这也返回状态错误0

+2

你可以发布你的代码,给出问题。我们很容易回答你的问题 – 2012-07-12 10:34:49

+0

我所有的异步函数都有这种行为。我通过套接字发送一些信息。我的功能正在工作,但只有当我重新加载浏览器才能得到答案时,我有错误0。 – Heniek 2012-07-12 10:37:50

+0

尚不清楚为什么在获得结果之前重新加载浏览器。 – 2012-07-12 10:46:04

回答

0

你总是可以定义onFailure()像这样(改编自GWT API)能够很好地处理不同类型的故障:

public void onFailure(Throwable caught) { 
    try { 
    throw caught; 
    } catch (IncompatibleRemoteServiceException e) { 
    // this client is not compatible with the server; cleanup and refresh the 
    // browser 
    } catch (InvocationException e) { 
    // the call didn't complete cleanly 
    } catch (YourOwnException e) { 
    // take appropriate action 
    } catch (Throwable e) { 
    // last resort -- a very unexpected exception 
    } 
} 
+0

你真的仍在使用GWT 1.5,或者只是在链接到javadocs时出错吗?现在我们已经达到了2.5(几乎),并且2.0已经在3年前发布了! – 2012-07-12 12:11:39

+0

@ThomasBroyer:我只是一个不幸的链接选择。虽然页面在1.5到2.5是相同的。更新了链接。 – Keppil 2012-07-12 13:08:19