Results 1 to 3 of 3

Thread: Error handling with store

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    85
    Answers
    6

    Default Answered: Error handling with store

    I'm looking for a way to handle server thrown errors 400 404 blah blah you know the drill

    but so far I haven't found a good way to do this that actually WORKS...
    I've seen crap with loadexception but I'm guessing this is for an older version so that's the deadest end I could've found.

    there's if(success)
    in load but then I get a message the framework itself generates whereas the actual server message (which I don't find in ANY of the load objects) is:
    1) translated
    2) exactly about what's being requested

    any help is appreciated

  2. You can create a listener on your model:

    Code:
    Ext.define('myModel', {
        extend: 'Ext.data.Model',
        idProperty: 'id',
        fields: [..],
        proxy: {
            type: 'ajax',
            actionMethods: 'POST',
            api: {..},
            reader: {..},
            writer: {..},
            listeners: {
                exception: function(proxy, response, operation) {
                    Ext.MessageBox.show({
                        title: 'REMOTE EXCEPTION',
                        msg: operation.getError(),
                        icon: Ext.MessageBox.ERROR,
                        buttons: Ext.Msg.OK
                    });
                }
            }
        }
    });
    You could also add requestexception listener to Ext.data.Connection

    Regards,
    Scott.

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    You can create a listener on your model:

    Code:
    Ext.define('myModel', {
        extend: 'Ext.data.Model',
        idProperty: 'id',
        fields: [..],
        proxy: {
            type: 'ajax',
            actionMethods: 'POST',
            api: {..},
            reader: {..},
            writer: {..},
            listeners: {
                exception: function(proxy, response, operation) {
                    Ext.MessageBox.show({
                        title: 'REMOTE EXCEPTION',
                        msg: operation.getError(),
                        icon: Ext.MessageBox.ERROR,
                        buttons: Ext.Msg.OK
                    });
                }
            }
        }
    });
    You could also add requestexception listener to Ext.data.Connection

    Regards,
    Scott.

  4. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    85
    Answers
    6

    Default

    Quote Originally Posted by scottmartin View Post
    You can create a listener on your model:

    Code:
    Ext.define('myModel', {
        extend: 'Ext.data.Model',
        idProperty: 'id',
        fields: [..],
        proxy: {
            type: 'ajax',
            actionMethods: 'POST',
            api: {..},
            reader: {..},
            writer: {..},
            listeners: {
                exception: function(proxy, response, operation) {
                    Ext.MessageBox.show({
                        title: 'REMOTE EXCEPTION',
                        msg: operation.getError(),
                        icon: Ext.MessageBox.ERROR,
                        buttons: Ext.Msg.OK
                    });
                }
            }
        }
    });
    You could also add requestexception listener to Ext.data.Connection

    Regards,
    Scott.
    worked like a charm to get me to the answer. I tried that listener on the store, on the reader but not the proxy xP

    I just used the response (with decode) instead of operation to get me the original server message.

    thanks for the help

Tags for this Thread

Posting Permissions

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