3 ms·
> I think (but can be wrong) that by using such a dynamic environment like JS is the culprit for lack of good error checking mechanism. Not at all. It's perfec
by bartread 6y ago
> I think (but can be wrong) that by using such a dynamic environment like JS is the culprit for lack of good error checking mechanism.
Not at all. It's perfectly possible to implement solid error handling. There's even a global handler: https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror https://developer.mozilla.org/en-US/docs/Web/API/GlobalEvent....
For legacy scenarios (IE11) you can add an event handler for the error event, so you end up with something like the following to deal with both situations:
window.onerror = yourErrorHandlerFunction;
window.addEventListener('error', yourErrorEventHandlerFunction);
The shape of the objects passed in differs slightly, hence the need for two different handlers. In my case one simply repackages the object and hands it off to the other.