Last active
July 1, 2019 07:04
-
-
Save WoZ/a8da8b224b01a55fe3b2c18ec008bd0f to your computer and use it in GitHub Desktop.
promise_executor_error_handling.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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