Opened 12 years ago

Last modified 3 years ago

#6765 assigned enhancement

JSON Procedure Call: error handling

Reported by: guest Owned by: Kris Zyp
Priority: low Milestone: 1.15
Component: RPC Version: 1.1.0
Keywords: RPC, JSON, error, exception needsreview Cc: alex
Blocked By: Blocking:

Description

Error object contains only HTTP error. Example:

       var myObject = new dojo.rpc.JsonService("/definition.smd");
       var myDeferred = myObject.add(121,5});
       myDeferred.addCallback(myCallbackMethod);
       myDeferred.addErrback(myErrorbackMethod);

Exception thrown deliberately in PHP file (token is not defined).

if (
Sessions::get()->getToken()
!== Request::get()->getRpcParams('token')
) :
throw new Exception('RPC Server: Invalid token', 3006);
endif;

Result:

  message : Unable to load /rpcServer.php status:400
  fileName : https://www.somewebsite.org/js/dojo/_base/_loader/bootstrap.js
  lineNumber : 475
  stack : Error("Unable to load /rpcServer.php status:400")@:0
([object Error])@https://www.somewebsite.org/js/dojo/_base/_loader/bootstrap.js:475
()@https://www.somewebsite.org/js/dojo/_base/_loader/bootstrap.js:762
([object Error])@https://www.somewebsite.org/js/dojo/_base/_loader/bootstrap.js:678
([object Error])@https://www.somewebsite.org/js/dojo/_base/_loader/bootstrap.js:710
([object Object])@https://www.somewebsite.org/js/dojo/_base/_loader/bootstrap.js:975
(-3)@https://www.somewebsite.org/js/dojo/_base/_loader/bootstrap.js:889

  name : Error

Expected: Have access to exception data including optional field data as specified in JSON-RPC over HTTP.

 responseText : {"result":null,"error":{"code":-32600,"message":"Invailid request.","data":"RPC Server: Invalid token"},"id":null}

Resolution: In RpcService?.js on line 83 entire object data should be passed and not only property message congaing only HTTP message. Current code:

deferredRequestHandler.errback(new Error(data.message));

Suggested change:

deferredRequestHandler.errback(new Error(data));

In this manner developer would have chance to fine tune error handling.

Change History (9)

comment:1 Changed 12 years ago by guest

Actually since in every case data is already error object line new error object should not be created. Line 86 should read:

			deferredRequestHandler.errback(data);

comment:2 Changed 11 years ago by bill

Milestone: tbd

mark all (open) tickets w/blank milestones to be "tbd"; their milestones need to be set to a version number or to "future"

comment:3 Changed 11 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

(In [14792]) fixes #6765

comment:4 Changed 11 years ago by dylan

Milestone: tbd1.2

comment:5 Changed 9 years ago by Jan Schatz

Resolution: fixed
Status: closedreopened

changeset:14792 didn't solve the problem, but made it worse. Now instead of passing the complete error object only the error message is passed to the errback. This is not compatible with previous version.

comment:6 Changed 8 years ago by ben hockey

Keywords: needsreview added
Owner: changed from Dustin Machi to Kris Zyp
Priority: highlow
Status: reopenedassigned

comment:7 Changed 7 years ago by bill

Milestone: 1.2tbd

comment:8 Changed 4 years ago by dylan

Milestone: tbd1.12

comment:9 Changed 3 years ago by dylan

Milestone: 1.131.15

Ticket planning... move current 1.13 tickets out to 1.15 to make it easier to move tickets into the 1.13 milestone.

Note: See TracTickets for help on using tickets.