Skip to content

Instantly share code, notes, and snippets.

@WoZ
Last active July 1, 2019 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WoZ/a8da8b224b01a55fe3b2c18ec008bd0f to your computer and use it in GitHub Desktop.
Save WoZ/a8da8b224b01a55fe3b2c18ec008bd0f to your computer and use it in GitHub Desktop.
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