Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

RPCManager handleError method not called on server's side RuntimeException

$
0
0
Hi,

GWT Version : 2.6.1
SmartGWT Version : 5.0-p20141210
Firefox version : 24
JBoss EAP 6.1+

We don't use SmartGWT server, our server is a JBoss where we have implemented REST Web Services.

On client side, we do use SmartGWT REST datasources.

---------------------
-- SERVER SIDE --
---------------------

When we have a business logic error, we perform a :
Code:

throw new RuntimeException("my businness logic error message");
We have defined our implementation of interface ExceptionMapper in order make server side Exceptions reach client as REST formated Exceptions
Code:

javax.ws.rs.ext.ExceptionMapper<E extends Throwable>
--------------------
-- CLIENT SIDE --
--------------------

On module load, we override RPCManager error handler methods :

Code:

GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
  @Override
  public void onUncaughtException(final Throwable e) {
    SC.warn("onUncaughtException");
  });

RPCManager.setHandleErrorCallback(new HandleErrorCallback() {
  @Override
  public void handleError(final DSResponse dsResponse, final DSRequest dsRequest) {
    SC.warn("handleError");
  });

RPCManager.setHandleTransportErrorCallback(new HandleTransportErrorCallback() {
  @Override
  public void handleTransportError(final int i, final int i1, final int i2, final String s) {
    SC.warn("handleTransportError");
  });

------------------------------
-- 1ST CASE : WORKING --
------------------------------

I have a DynamicForm with my databinded FormItem's.
I perform a :

Code:

myForm.saveData()
It works perfectly and when i'm in the case I generate a RuntimeException on server side, methods handleTransportError and handleError overriden previously are beeing called.

First handleTransportError then handleError.

I retrieve my businness logic error message from handleTransportError method (I simplified the code above for this thread).


------------------------------------
-- 2ND CASE : NOT WORKING --
------------------------------------

Now, I have a databinded ListGrid on which i perform :

Code:

grid.removeSelectedData();
It works perfectly by when i'm in the case I generate a RuntimeException on server side, only method handleTransportError overriden previously is beeing called.

The handleError method is actually not called.

I added a callback on removeSelectedData method :

Code:

grid.removeSelectedData(new DSCallback() {
  @Override
  public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
    if (dsResponseStatus != DSResponse.STATUS_SUCCESS) {
    String httpResponseText = dsResponse.getAttribute("httpResponseText");
    final JSONValue body = JSONParser.parseStrict(httpResponseText);
    final JSONObject response = body.isObject().get("response").isObject();
    final String errorMessage = response.get("errors").isString().stringValue();
    SC.warn(errorMessage);
  }
});

Callback on removeSelectedData method is being called.

I retrieve my business logic error message in both :
- callback of removeSelectedData method
- handleTransportError method


I have my workaround but i want to understand why handleError method is not called on my 2nd case, it bothers me !

What i am missing on my client side to make it works as it should be, in RPCManager methods overriden.

thanks by advance.

Viewing all articles
Browse latest Browse all 4756

Trending Articles