3 ms·
Sure you do. If you care about exceptions, your callback routines or event handlers should use try/catch themselves. This is true regardless of the other machin
by jerf 18y ago
Sure you do. If you care about exceptions, your callback routines or event handlers should use try/catch themselves. This is true regardless of the other machinery; browser event handling or higher-level library, the upper layers do not know what to do with a failing callback. Your objection is meaningless because it's true independent of what is being discussed.
Furthermore...
for (var idx in callback_array) {
var callback_data = callback_array[idx];
var callback = callback_data.callback;
var error_handler = callback_data.error_handler;
try {
callback();
} catch (err) {
try {
error_handler(err);
} catch (ignore) {}
}
}
there is nothing intrinsic about "not being able to handle your own errors", either. (This is obviously simplified.) I don't think I'd implement, this, though; I'd say if you want to handle exceptions, handle exceptions within the callback.
Most implementations of callback loops suck, but this is the fault of the implementors, not the idea.
- deleted 18y ago[deleted]