Exception Handling on Data source

Hi,

I am using SmartGWT EE 2.4.

We have used the Isomorphic Data sources to integrate the data interactions. But even when there is an exception on server side (any Java exception , like NPE) , the Data source’s execute callback is invoked.

I have also defined addHandleErrorHandler with the logic to handle exceptions , but always the execute method gets invoked in the callback.

Thanks,
Ravi.

That’s not the default behavior (try modifying any sample to have it throw an exception to prove this). Possibly you have set rpcRequest.willHandleError.

I have set the setWillHandleError(true) on the DSRequest and also defined an error handler on the datasource which is as below.

I also have a RPCManager.setHandleErrorCallback with code display the error in an alert and an GWT.setUncaughtExceptionHandler

But even after exceptions the excute() method of the DS callback is executed.

Also please suggest if there is a good example of doing exception handling for an entire GWT app.

.addHandleErrorHandler(new HandleErrorHandler() {
                			
                			public void onHandleError(ErrorEvent event) {
                				event.cancel(); // This is done to prevent error from Propagating further.
                				SC.clearPrompt();
                				String errorMsg = "";
                				if (event!=null && event.getResponse()!=null && event.getResponse().getErrors()!=null)
                					errorMsg = event.getResponse().getErrors().toString();
                				displayErrorMessage("Error : "+errorMsg);
                				
                			}
                		});

Thanks,
Ravi

If you set willHandleError(true), then it’s expected that the DSCallback is executed. That’s what willHandleError does and is documented to do. Set willHandleError(false), or just leave it unset, to allow DSResponses with an error status to go to the RPCManager HandleErrorCallback.

Note this is totally independent of client-side exception handling and the UncaughtExceptionHandler. The mechanisms discussed above control what happens when an RPCResponse or DSResponse has an error status when received by the client.

Hi,

I have updated my code and explictly set the setWillHandleError to False.

But still the execute method gets executed. , I have also checked the

if (response.getStatus() == RPCResponse.STATUS_SUCCESS)

in the execute method and this returns True.

The response i Am getting from the Server is
HTTP Response Code : 200
Response Body:
<BR>com.isomorphic.servlet.IDACall top-level exception<BR>
<PRE>
java.lang.NullPointerException
at org.apache.catalina.connector.Request.parseParameters(Request.java:2340)
at org.apache.catalina.connector.Request.getParameter(Request.java:996)
at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:343)
at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:157)
at com.isomorphic.rpc.RPCManager.initLog(RPCManager.java:329)
at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:284)
at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:271)
at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:90)
at com.isomorphic.servlet.IDACall.doPost(IDACall.java:54)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

First of all, as you correctly pointed out here, this exception arises from a limitation in Tomcat. This means that SmartGWT server code is not even involved in this error display - SmartGWT just receives an HTTP 200 (which actually indicates “OK” - it’s not clear why Tomcat uses this code in this case) and the text of the exception.

Whether this is considered a valid response or not is based on your DataSource declaration and how you are calling the DataSource, so please show that code.