Hi,
I am trying to get smartclient talk to a json-rpc 2.0 (draft) compatible server. Unfortunately I am running into troubles with getting back error messages.
Can you please:
a) Confirm that I am on the right track regarding a way to talk to jsonrpc and do not follow a stupid way since there are better ones?
b) Maybe tell me a way how to get errors presented to the user?
c) Maybe tell me a way how to solve the http status issue?
Also, if I am right, error handling of http errors is currently not in place. Think it would be great if it would be. :)
Thanks a lot in advance for your help!
The details:
First hurdle is that the preferred way to contact json-rpc is with a POST - also for fetching. Also the data structures are quite a bit different to what RestDataSource expects. Instead of overwriting nearly everything in RestDataSource I started to write my own data source JsonRPCDataSource based on RestDataSource.
So far fetch works fine but as soon as an error occures I run into troubles. JsonRPC over http maps errors also into the http status. And if smartclient gets a e.g. http status 500 the code does not even reach my transformResponse function but fails earlier in DataSource.js in the _handleJSONTextReply function at the line
with an error
This is what the developer console says to it:
For the user all this is hidden. No feedback. Just the "Finding records that match your criteria..." window blocking everything else. The only thing a user can do is to hit the browser's refresh button.
Well, I came to the conclusion that currently without rewriting smartclient code there is no way how to deal with http error codes. Just for testing I changed the backend to always send http 200 status codes - also for errors.
My transformResponse deals with the different data structure (I think :)) and should map them to the dsResponse structure. But I never see an error message in the user interface. Just "No items to show." in the ListGrid.
To shorten things I tried to force an error by rewriting my transformResponse this way:
pid is a field in my ListGrid and data source. Still no difference.
The console is well aware of the error:
Regards,
Erich
PS: Just in case, the respective json-rpc specifications can be found under:
http://groups.google.com/group/json-...c-1-2-proposal
http://groups.google.com/group/json-...-rpc-over-http
edit: Maybe I should also mention that I am using:
dataFormat: "json"
and
dataProtocol:"postMessage"
I am trying to get smartclient talk to a json-rpc 2.0 (draft) compatible server. Unfortunately I am running into troubles with getting back error messages.
Can you please:
a) Confirm that I am on the right track regarding a way to talk to jsonrpc and do not follow a stupid way since there are better ones?
b) Maybe tell me a way how to get errors presented to the user?
c) Maybe tell me a way how to solve the http status issue?
Also, if I am right, error handling of http errors is currently not in place. Think it would be great if it would be. :)
Thanks a lot in advance for your help!
The details:
First hurdle is that the preferred way to contact json-rpc is with a POST - also for fetching. Also the data structures are quite a bit different to what RestDataSource expects. Instead of overwriting nearly everything in RestDataSource I started to write my own data source JsonRPCDataSource based on RestDataSource.
So far fetch works fine but as soon as an error occures I run into troubles. JsonRPC over http maps errors also into the http status. And if smartclient gets a e.g. http status 500 the code does not even reach my transformResponse function but fails earlier in DataSource.js in the _handleJSONTextReply function at the line
Code:
if (evalText.match(/^\s*\{/)) {
Code:
evalText.match is not a function
Code:
20:10:00.343:XRP6:WARN:Log:Error: 'Object doesn't support this property or method' in http://localhost:8001/ at line 297 DataSource.$379(rpcResponse=>Obj, jsonText=>Array[1], rpcRequest=>Obj) Class.fireCallback(_1=>Obj, _2=>"rpcResponse,data,rpcRequest", _3=>Array[3], _4=>[JsonRPCDataSource ID:processListDS], _5=>undef) on [Class Class] Class.fireCallback(_1=>Obj, _2=>"rpcResponse,data,rpcRequest", _3=>Array[3], _4=>undef) "return isc.Class.fireCallback(_1,_2,_3,this,_4)" RPCManager.fireReplyCallback(_1=>Obj, _2=>Obj, _3=>Obj, _4=>Array[1]) RPCManager.fireReplyCallbacks(_1=>Obj, _2=>Obj) RPCManager.performOperationReply(_1=>Obj, _2=>Obj) RPCManager.$39d(_1=>2) RPCManager.performTransactionReply(_1=>2, _2=>Array[1], _3=>undef) callback(transactionNum=>2, results=>Obj, wd=>undef) "isc.RPCManager.performTransactionReply(transactionNum,results,wd)" ** recursed on Class.fireCallback
Well, I came to the conclusion that currently without rewriting smartclient code there is no way how to deal with http error codes. Just for testing I changed the backend to always send http 200 status codes - also for errors.
My transformResponse deals with the different data structure (I think :)) and should map them to the dsResponse structure. But I never see an error message in the user interface. Just "No items to show." in the ListGrid.
To shorten things I tried to force an error by rewriting my transformResponse this way:
Code:
transformResponse : function (dsResponse, dsRequest, data) { dsResponse.status = isc.DSResponse.STATUS_VALIDATION_ERROR; dsResponse.errors = { pid:[ {errorMessage:"First error on field1"}, {errorMessage:"Second error on field1"} ] }; dsResponse.data = { pid:[ {errorMessage:"First error on field1"}, {errorMessage:"Second error on field1"} ] }; return dsResponse;}
The console is well aware of the error:
Code:
21:43:08.515:XRP0:WARN:RPCManager:Error performing rpcRequest: error: VALIDATION_ERROR, response: {data: Obj, startRow: 0, status: -4, endRow: 0, totalRows: 0, httpResponseCode: 200, transactionNum: 2, clientContext: Obj, context: Obj, errors: Obj}
Erich
PS: Just in case, the respective json-rpc specifications can be found under:
http://groups.google.com/group/json-...c-1-2-proposal
http://groups.google.com/group/json-...-rpc-over-http
edit: Maybe I should also mention that I am using:
dataFormat: "json"
and
dataProtocol:"postMessage"
Comment