I have a function main
which contains a promise but does not return one. Something like this.
function main() {
var prom = new Promise(function(resolve, reject) {
setTimeout(() => {
console.log("testing");
reject();
}, 2000);
});
return "success";
}
main();
When I run the code, it gives an Uncaught (in promise) DOMException and stops the javascript code. I can't modify the main
function at all. How can I catch the rejection?