[TIMOB-1057] iOS: Exceptions failing in event listeners
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2012-07-25T12:43:24.000+0000 |
Affected Version/s | Release 1.5.0 |
Fix Version/s | n/a |
Components | iOS |
Labels | n/a |
Reporter | ctredway |
Assignee | Neeraj Gupta |
Created | 2011-04-15T02:42:45.000+0000 |
Updated | 2012-07-26T22:25:12.000+0000 |
Description
a customer has reported that if there is a coding issue (i.e. missing var) in an event listener, that error fails to be registered in Developer. Following code shows this behavior.
var i=0;
i.missingMethod();
appropriately logs the exception but
btn.addEventListener('click', function() {
var i=0;
i.missingMethod();
});
does not.
Comments
- Stephen Tramer 2011-04-15
This is a threading issue, certainly. We don't catch and report exceptions that occur on some threads.
- Damien Elmes 2011-04-15
I hit this issue so often that I don't call addEventListener() directly anymore, and instead use:
var listen = function(obj, event, cb) { obj.addEventListener(event, function (e) { try { cb(e); } catch (err) { alert("Error in callback: " + err); } }); };
- Matthew Lieder 2011-04-15
That's a great idea Damien; I'm embarrassed I never even thought of doing that. Keep forgetting how flexible Javascript is. Thanks! That'll be a great duct-tape bandage until they fix this.
- David Rodriguez 2011-12-18 Is there any way to do a stack trace with a try and catch?
- Stephen Tramer 2012-07-25
Cannot reproduce described issue in SDK 2.2.0.f9e938d with iPhone Sim 5.1.
This logs information in the console indicating an exception has occurred.var i=0; i.missingMethod(); appropriately logs the exception but btn.addEventListener('click', function() { var i=0; i.missingMethod(); });