I have a function that may throw an exception. I would like to expose this exception as if it were thrown (in fact, the same user interface experience, so that it displays as an exception in the browser and console window, any debugging tools). But I do not want the exception to stop the execution of the original function. One solution to this problem is to catch and re-throw an exception, but inside setTimeout (). Thus, it will be called later, but does not interrupt the function due to which it occurred.
Example:
var f = function() {
try {
} catch (e) {
setTimeout(
function() {
throw e;
},
100
);
}
}
, ? ( , ?) JavaScript? - ?
: console.log console.error, , console.log , throw e.