admin管理员组

文章数量:1434972

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?

Share Improve this question edited Jul 26, 2013 at 19:32 drvdijk 5,5542 gold badges31 silver badges48 bronze badges asked Jul 26, 2013 at 18:40 John JaiJohn Jai 3,7337 gold badges26 silver badges35 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

See

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

本文标签: javascriptGlobal error handling in ExtJSStack Overflow