Note that there are some explanatory texts on larger screens.

plurals
  1. POGWT: What to expect when an HTTP request fails
    primarykey
    data
    text
    <p>I'm sending an HTTP request with RequestBuilder.send(). I would expect to see successful responses come back in onResponseReceived(), and errors come back in onError(). But that's not what I'm seeing. GWT calls onResponseReceived() regardless of success or failure.</p> <p>Does anyone know what I should really expect? Do you have any information that would help me detect and report errors better?</p> <p>Here's some sample code:</p> <pre><code> builder.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { Header[] debugHeaders = response.getHeaders(); String debugHeaders1 = response.getHeadersAsString(); int debugStatusCode = response.getStatusCode(); String debugStatusText = response.getStatusText(); String debugText = response.getText(); handleResponse(response); } @Override public void onError(Request request, Throwable exception) { reportError(); } }); </code></pre> <p>I can force an error on my computer by disabling the Wi-Fi. In that case onResponse() is called. getHeaders() returns an array of length 1, with the only entry set to null. getHeadersAsString returns "". getStatusCode returns 0. getStatusText() returns "". getText() returns "".</p> <p>If this is always the case, I can look for that in my code. However, I expect that different browsers, different errors, etc, will cause a different result. Is there any good way to always detect an error?</p> <p>(As long as there are no HTTP problems, my code works fine.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload