ExstJs Store callback proper error handling

Viewed 13520

I want to receive a personalized error message when trying to load a store and my connection times out or the DB it's not accessible ... when I do an Ajax Request is very easy because I get "response" as a parameter either in success or failure ...

Ext.Ajax.request({
   url: 'ajax_demo/sample.json',
   success: function(response, opts) {
      var obj = Ext.decode(response.responseText);
      console.dir(obj);
   },
   failure: function(response, opts) {
      console.log('server-side failure with status code ' + response.status);
   }
});

But I'm facing problems to do the same when trying to load a store, I've defined a callback function but I only receive records, operation and success.

store.load({
        callback : function(records, options, success) {
            if (!success) {

              // what can I do here to show personalized error sent from server
            }
        }
    });

So, what is the proper way to handle a response like this to show it to the user?

{"success": false, "msg": "SomeExceptionFromServer"}

Best regards

3 Answers
Related