Quantcast
Channel: JavaScript global event mechanism - Stack Overflow
Viewing all articles
Browse latest Browse all 10

Answer by SunnyRed for JavaScript global event mechanism

$
0
0

sophisticated error handling

If your error handling is very sophisticated and therefore might throw an error itself, it is useful to add a flag indicating if you are already in "errorHandling-Mode". Like so:

var appIsHandlingError = false;window.onerror = function() {    if (!appIsHandlingError) {        appIsHandlingError = true;        handleError();    }};function handleError() {    // graceful error handling    // if successful: appIsHandlingError = false;}

Otherwise you could find yourself in an infinite loop.


Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>