View Full Version : Ext.Error handler is not catching all exception and errors

11 Jun 2012, 7:07 PM
Hi all,

I am using following code to handle all the error in ExtJs.

Ext.Error.handle (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Error-static-method-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

I have added this code in launch() of app.js file.

Problem: While this function handles error from ExtJs framework or error generated using Ext.Error.riase(), it does not catch other javasacript errors. I want to write a generic function which should handle all the errors. Please suggest solutions.

28 Jun 2012, 8:02 AM
Use window.onError and attach your function to it.
If you need a stacktrace also to be printed, I recommend the one mentioned in this stackoverflow question: http://stackoverflow.com/questions/3283576/how-to-trace-javascript-events-stack-trace

(http://stackoverflow.com/questions/3283576/how-to-trace-javascript-events-stack-trace)Note that in Google Chrome, window.onError does not hold the stacktrace of the actual error, which is a huge disappointment considering the browser is perfect almost everywhere else.

28 Jun 2012, 7:04 PM
Hi Reimius,

Thank you for the reply. I tried using onError event but it does not catch all the errors. I know its strange but it is not catching all the erros.

Thank you.

29 Jun 2012, 6:18 AM
What is it not catching? Syntax errors?

3 Jul 2012, 12:37 AM
It's not catching null reference exceptions and systax error (like trailing comma's).

3 Jul 2012, 5:32 AM
Syntax errors should be caught before going into production, how would a page even work with them? And onerror does work for null reference errors as far as I know, are you sure you're talking about the right thing?