3 ms·
The problem is that the try/catch part is implemented in the library. It is impossible for library developers to know how it should handle your exceptions, and
by Gonsalu 18y ago
The problem is that the try/catch part is implemented in the library.
It is impossible for library developers to know how it should handle your exceptions, and you don't get to catch your exceptions, so there's no advantage whatsoever in using the try/catch.
- jerf 18y agoSure 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]