I am trying to make my code a little more reliable by handling all kinds of exceptions that may occur. One may be a 404 exception in a Json web request. It looks like the store.load callback method is not called when the Json request receives exception 404.
The code:
Ext.regModel('Activiteit', { fields: [ { name: 'id', type: 'int' }, { name: 'ServerId', type: 'int', mapping: 'Id' }, { name: 'Title', type: 'string' }, { name: 'Description', type: 'string' }, ], }); Ext.regApplication({ name: 'App', launch: function () { console.log('launch'); var ajaxActiviteitStore = new Ext.data.Store({ model: "Activiteit", storeId: 'ajaxActiviteitStore', proxy: { type: 'ajax', url: '/senchatest/Activiteit/Gett/', reader: { type: 'json', root: 'activiteiten' } } }); ajaxActiviteitStore.load(function (records, operation, success) {
As a result, the message "Uncaught TypeError: Can not read length" from undefined "appears on line 7212 sencha-touch-debug.js. I am using version 1.1.0 for sencha touch.
Stack:
Uncaught TypeError: Cannot read property 'length' of undefined Ext.data.Store.Ext.extend.loadRecords sencha-touch-debug.js:7212 Ext.data.Store.Ext.extend.onProxyLoad sencha-touch-debug.js:7024 (anonymous function) sencha-touch-debug.js:8742 Ext.data.Connection.Ext.extend.onComplete sencha-touch-debug.js:17566 Ext.data.Connection.Ext.extend.onStateChange sencha-touch-debug.js:17513 (anonymous function) sencha-touch-debug.js:3421
What am I doing wrong here?
I found a workaround by adding a listener to the proxy server that listens for the "exception" event, but I would prefer the calling function of the called store load to be called. Am I doing something wrong or is this the default behavior?
Thanks,
Sander
exception-handling extjs sencha-touch
SanderS
source share