Created
October 22, 2012 00:48
-
-
Save forcementor/3929119 to your computer and use it in GitHub Desktop.
Developing Mobile…Force.com and Sencha-Part 3, Step 3: Repair the error listener code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//THIS IS THE FLAWED CODE! | |
//Listen for exceptions observed by the proxy so we can report them and clean up. | |
Ext.getStore('Leads').getProxy().addListener('exception', function (proxy, response, operation, options) { | |
// only certain kinds of errors seem to have useful information returned from the server | |
if (response.data) { | |
if (response.data.errorMessage) { | |
Ext.Msg.alert('Error', response.data.errorMessage); | |
} else { | |
Ext.Msg.alert('Error', operation.action + ' failed: ' + response.data.message); | |
} | |
} else { | |
Ext.Msg.alert('Error', operation.action + ' failed for an unknown reason'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//THIS IS THE REPAIRED CODE! | |
//Listen for exceptions observed by the proxy so we can report them and clean up. | |
Ext.getStore('Leads').getProxy().addListener('exception', function (proxy, response, operation, options) { | |
// only certain kinds of errors seem to have useful information returned from the server | |
if (response) { | |
if (response.errorMessage) { | |
Ext.Msg.alert('Error', response.errorMessage); | |
} else { | |
Ext.Msg.alert('Error', operation.config.action + ' failed: ' + response.errorMessage); | |
} | |
} else { | |
Ext.Msg.alert('Error', operation.config.action + ' failed for an unknown reason'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment