There is a script error in the function definition below
function foo () {
try {
var bar = function() {
ERROR
}
} catch (exception) {
console.debug("exception");
}
}
foo();
But the catch failed as the bar function is not executed. Is it possible to catch those error with really running the function?
Thanks.
That’s not possible.
Only Synrax errors are caught without calling the function. Other errors, such as the Reference error, are dependent on when they’re called. It’s not possible to determine whether a function is going to throw a
ReferenceErroror not.Example: