Is there a way to handle all JavaScript errors and exceptions in ExtJS application globally and route it to a function that alerts the user on a server error?
window:onerror()
doesn't seem to handle all the JavaScript errors, hence looking for some kind of catch in the code, to wrap it in to a more generic exception so that it would be caught?
Is there a way to handle all JavaScript errors and exceptions in ExtJS application globally and route it to a function that alerts the user on a server error?
window:onerror()
doesn't seem to handle all the JavaScript errors, hence looking for some kind of catch in the code, to wrap it in to a more generic exception so that it would be caught?
1 Answer
Reset to default 3See
http://docs.sencha./extjs/4.2.1/#!/api/Ext.Error-static-method-handle
Globally handle any Ext errors that may be raised, optionally providing custom logic to handle different errors individually. Return true from the function to bypass throwing the error to the browser, otherwise the error will be thrown and execution will halt.
Example usage:
Ext.Error.handle = function(err) {
if (err.someProperty == 'NotReallyAnError') {
// maybe log something to the application here if applicable
return true;
}
// any non-true return value (including none) will cause the error to be thrown
}
Normally an error would get handled by onerror, but returning true in Ext.Error.handle prevents that.
Also look at http://docs.sencha./extjs/4.2.1/#!/api/Ext.Ajax-event-requestexception