Hi,
I am wondering how can I retrieve (at client side, from the RPCManager HandleErrorCallback) the contents of the response "data" attribute when it contains an error message (as suggested in various threads for generic errors not related to validation failures).
In practice, I have a RestDataSource, that's getting a JSON response with the attribute "status" to -1 and the "data" attribute containing the error message:
I'm using the HandleErrorCallback only to have a general way to format the contents of the error message dialog, and let the dialog show only the error message, as (I think by default) it shows the entire response contents:
The DSResponse.getData() is not compatible cause it offers a Record array, and with response.getAttribute ("data") I only get a dialog saying "[object OBJECT]"...
This is a snippet of my last HandleErrorCallback experiment
At client side I'm using
SmartClient Version: 8.0/LGPL Development Only (built 2010-05-18)
GWT 2.0.4
Firefox 3.6.9
at server side Grails 1.3.4
Kind regards
Davide
I am wondering how can I retrieve (at client side, from the RPCManager HandleErrorCallback) the contents of the response "data" attribute when it contains an error message (as suggested in various threads for generic errors not related to validation failures).
In practice, I have a RestDataSource, that's getting a JSON response with the attribute "status" to -1 and the "data" attribute containing the error message:
Code:
{"response":{"status":-1,"data":"Internal server error: java.lang.RuntimeException with message test error message"}}
Code:
Transport error: 500 - {"response":{"status":-1,"data":"Internal server error: java.lang.RuntimeException with message test error message"}}
This is a snippet of my last HandleErrorCallback experiment
Code:
RPCManager.setHandleErrorCallback (new HandleErrorCallback() { @Override public void handleError (DSResponse response, DSRequest request) { String errorMsg; try { errorMsg = response.getAttribute ("data"); } catch (final Exception e) { errorMsg = null; } if (errorMsg!=null) { SC.warn (StringUtil.abbreviate (errorMsg.toString (), 200)); } else { SC.warn ("Internal server error"); } } });
SmartClient Version: 8.0/LGPL Development Only (built 2010-05-18)
GWT 2.0.4
Firefox 3.6.9
at server side Grails 1.3.4
Kind regards
Davide
Comment