PDA

View Full Version : Global exception hook



oyvinht
28 Oct 2010, 11:50 PM
Greetings,

what is the preferred way to catch unhandled exceptions when using Ext JS?

WebKit browsers do not support window.onerror, so for now I have tried to hook into the Ext JS event manager like this (it's a Sencha Touch app):



Ext.setup(
{
phoneStartupScreen: 'images/phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,
onReady: function() {

var origAddListener = Ext.EventManager.addListener;
Ext.EventManager.addListener = function(element, eventName, fn, scope, o){
handledFn = function() {
try{
fn.apply(scope, arguments);
} catch (x) {
console.log(x);
}
};
origAddListener.call(this, element, eventName, handledFn, scope, o);
};


But this will only catch events thrown from listener code, of course. Is there a better way?

--
ěyvin

jsakalos
29 Oct 2010, 3:38 AM
Wrong forum? Moving this thread to Sencha Touch forum.