TiLogCatcher
TiLogCatcher copied to clipboard
Prevent loop
If the code in the listener creates another JS error, you'll get in a loop. Would there be a way for the module to prevent this?
Workaround is to use try/catch in the listener of course :)
Can you give me an example that will cause it?
Sure:
require("yy.logcatcher").addEventListener('error', troubleMaker);
var win = Ti.UI.createWindow({
backgroundColor: 'white'
});
var btn = Ti.UI.createButton({
title: 'Click Me'
});
btn.addEventListener('click', troubleMaker);
win.add(btn);
win.open();
function troubleMaker() {
JSON.parse('foo');
}
That deserves an infinite loop. PR?
That's why it's a good use case, but of course in real world the problem is edge cases where depending on the error, and external factors influencing how it's handled that you'd run into the loop.
I'm not much good in Obj-C/JAVA I'm afraid. And since it's an edge case, I don't need it to be fixed soon. Just let this ticket sit here so we are aware ;)