2012-07-12 58 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