Skip to content

Instantly share code, notes, and snippets.

@forcementor
Created October 22, 2012 00:48
Show Gist options
  • Save forcementor/3929119 to your computer and use it in GitHub Desktop.
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 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 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