Announcement
Collapse
No announcement yet.
X
-
There was a problem specific to LGPL version. Now it is fixed.
You can test it with latest build (from 2017-06-13).
Leave a comment:
-
Hi Blama,
The point of this thread is that the global error handler registered by RPCManager.setHandleErrorCallback() is not called for RPCRequests, at least as I experience (note that it does work for DSRequests).
Therefore, in this repro case, we need that the requests fail at server side, so that the error handler has the chance to be called. So I didn't register IDACall, with which I achieve the server side failure.
Best,
ilab
Leave a comment:
-
Thank you for the reply.
I have just run your code but as far as I can see the error handler did run only once. I attach a screenshot of the log for reference.
The environment and versions are the same as above stated.
(I also note that my code did pretty much the same, I saw both outgoing requests in the console.)
Maybe there is something wrong with my setup?
Leave a comment:
-
Your code fails and thus there is no request to server.
Run this code and check developer console for messages. You will see that both requests execute error handler.
Code:import com.smartgwt.client.data.Criteria; import com.smartgwt.client.util.SC;
Code:@Override public void onModuleLoad() { RPCManager.setHandleErrorCallback(new HandleErrorCallback() { @Override public void handleError(DSResponse response, DSRequest request) { SC.logWarn("For request: " + request.toString()); SC.logWarn("Got response: " + response.toString()); } }); RestDataSource ds = new RestDataSource(); // Set dummy criteria ds.fetchData(new Criteria("id", "1")); RPCRequest rpc = new RPCRequest(); RPCManager.sendRequest(rpc); // Open developer console to view debug messages SC.showConsole(); }
Leave a comment:
-
Thank you - yes it seems there is a bug here:
your GWT version & Smart GWT version
2.8.1 & smartgwt-lgpl 6.0-p20170601
whether you were in GWT Hosted / Development mode or a normal browser
hosted
browser version and operating system
Chrome 58.0.3029.110 (64-bit) / Windows 7 Professional SP1
what you expected to happen, and, if applicable, the Smart GWT documentation that led you to believe your approach would work
See RPCManager#setHandleErrorCallback documentation, which states it works for both DSResponses and RPCResponses.
However, for a correct implementation the callback method signature should be handleError(RPCResponse response, RPCRequest request) instead of the current handleError(DSResponse response, DSRequest request).
You informed above that the framework creates a fake DSResponse/DSRequest so that the callback can be called but it doesn't seem to happen, the callback is not called in the case of an RPCRequest call error.
Please see a minimal sample code below.
In my understanding it should add two "handleError called" lines to the log but there is only one.
Please note that both requests get HTTP 404 response.
Code:package com.dummy.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.RestDataSource; import com.smartgwt.client.rpc.HandleErrorCallback; import com.smartgwt.client.rpc.RPCManager; import com.smartgwt.client.rpc.RPCRequest; public class dummyModule implements EntryPoint { public void onModuleLoad() { RPCManager.setHandleErrorCallback(new HandleErrorCallback() { @Override public void handleError(DSResponse response, DSRequest request) { GWT.log("handleError called"); } }); RestDataSource ds = new RestDataSource(); ds.fetchData(); RPCRequest rpc = new RPCRequest(); RPCManager.sendRequest(rpc); } }
Leave a comment:
-
There is indeed a small strangeness with the signature, where you will receive a RPCResponse "upgraded" to a DSResponse object, but of course with all properties intact, and the docs already explain how to tell the difference if you need to.
As far as claiming there's a bug here where the handler is not called, see the FAQ for how to report a bug - you not only don't have a test case, you forgot lots and lots of basics like what product and version and browser you are using.
Leave a comment:
-
RPCManager.setHandleErrorCallback vs RPCRequest
I would like to create a general error handler which works for both Datasources and RpcRequests.
As per the docs of RPCManager.setHandleErrorCallback:
handleError() will be called if RPCResponse.status is negative and RPCRequest.willHandleError was not set. It is called for both DSResponses and RPCResponses that have a non-success status. You can check whether the response is a DSResponse by checking response.isDSResponse.
Is it a bug or I miss something?Last edited by ilab; 15 May 2017, 06:48.Tags: None
Leave a comment: