Results 1 to 3 of 3

Thread: [DUPE-1413] DataProxy Exception - JsonReader - Possible Inconsistency

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Apr 2007
    Posts
    57
    Vote Rating
    2
      0  

    Default [DUPE-1413] DataProxy Exception - JsonReader - Possible Inconsistency

    Ext version tested:
    • Ext 3.1.1


    Adapter used:
    • ext




    Description:
    • In the readResponse method of a JsonReader, if a create action is being processed, a JsonReader error can be thrown before the success property is checked. If no records are present, this behavior results in a response exception back at the DataProxy. If the create action on the server fails, there will be no IDs to send back, however, it is still possible to send back a valid response.
      Put another way, if a create action fails due to a database constraint, (depending on the configuration of the JsonReader) you always end up with a raw response object rather than the decoded object.
      In order to get the remote exception, it is necessary to place an empty object in the records array.




    If the response has nothing in the records array:
    Code:
    {"records":[],"success":false,"message":"The record could not be created."}
    The exception type is "response" and message is undefined
    Code:
    Ext.data.DataProxy.addListener('exception', function() {
                //raw response Object -message is undefined
                    Ext.Msg.alert('Error', arguments[4].message);
          
          });


    If the response has an empty object in the records array
    Code:
    {"records":[{}],"success":false,"message":"The record could not be created."}
    The exception is the expected "remote" type and the decoded response is available.
    Code:
    Ext.data.DataProxy.addListener('exception', function() {
                    Ext.Msg.alert('Error', arguments[4].message);
          });








    • Here is the relevant method from JsonReader:
      Code:
      readResponse : function(action, response) {
              var o = (response.responseText !== undefined) ? Ext.decode(response.responseText) : response;
              if(!o) {
                  throw new Ext.data.JsonReader.Error('response');
              }
      
              var root = this.getRoot(o);
              if (action === Ext.data.Api.actions.create) {
                  var def = Ext.isDefined(root);
                  if (def && Ext.isEmpty(root)) {
                      throw new Ext.data.JsonReader.Error('root-empty', this.meta.root);
                  }
                  else if (!def) {
                      throw new Ext.data.JsonReader.Error('root-undefined-response', this.meta.root);
                  }
              }
      
              // instantiate response object
              var res = new Ext.data.Response({
                  action: action,
                  success: this.getSuccess(o),
                  data: (root) ? this.extractData(root, false) : [],
                  message: this.getMessage(o),
                  raw: o
              });
      
              // blow up if no successProperty
              if (Ext.isEmpty(res.success)) {
                  throw new Ext.data.JsonReader.Error('successProperty-response', this.meta.successProperty);
              }
              return res;
          },


      And here is the relevant point where the exception event is thrown from HttpProxy:

      Code:
       onWrite : function(action, o, response, rs) {
              var reader = o.reader;
              var res;
              try {
                  res = reader.readResponse(action, response);
              } catch (e) {
                  this.fireEvent('exception', this, 'response', action, o, response, e);
                  o.request.callback.call(o.request.scope, null, o.request.arg, false);
                  return;
              }
              if (res.success === true) {
                  this.fireEvent('write', this, action, res.data, res, rs, o.request.arg);
              } else {
                  this.fireEvent('exception', this, 'remote', action, o, res, rs);
              }
             
              o.request.callback.call(o.request.scope, res.data, res, res.success);
          },

  2. #2
    Ext JS Premium Member sumit.madan's Avatar
    Join Date
    May 2009
    Location
    Bangalore, India
    Posts
    126
    Vote Rating
    30
      0  

    Default

    Another 3 hours wasted due to this issue. Why is this bug hanging around since Feb? Still present in 3.2.2

  3. #3
    Sencha User
    Join Date
    Apr 2007
    Posts
    57
    Vote Rating
    2
      0  

    Default

    Looks like this has a fix [1413] : http://www.sencha.com/forum/showthread.php?117126

Similar Threads

  1. Correct exception handling with JSON and Dataproxy
    By Fredde in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 29 Mar 2010, 5:27 PM
  2. DataProxy exception after migrating to 3.0
    By stonefish in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 8 Jul 2009, 8:44 AM
  3. [2.x] Ext.data.JsonReader's totalRecords inconsistency
    By SamuraiJack1 in forum Ext 2.x: Bugs
    Replies: 10
    Last Post: 11 Aug 2008, 6:31 AM
  4. Replies: 3
    Last Post: 15 Nov 2007, 12:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •