Is it possible to catch undefined reference in global (window) scope is browser and require function instead of throwing error and without wrapping all functions in try-catch?
Example. I have function
$('#id').on('click', function(){
a();
})
If a
function is not defined, I just get an error Uncaught ReferenceError: a is not defined
What I want - is to define some global function that will catch all such errors, and require needed file (based on a map) instead of throwing errors.
I know it's possible in nodejs to catch any error, but is it possible in browser?