Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
promise_executor_error_handling.js
setTimeout(() => { process.exit(); }, 200);
function f() {
try {
return new Promise((resolve, reject) => {
throw new Error('Error: Threw right in the executor');
});
} catch (err) {
console.log('Error caught in f()', err);
}
}
const p = f();
p.then(() => {
console.log('Promise::then');
}).catch(err => {
console.log('Promise::catch', err.message);
});
// Promise::catch Error: Throwed right in the executor
// Process finished with exit code 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment