Last active
December 7, 2016 13:36
-
-
Save aherve/1ccfa53b640222193c8bfacb2f2b0509 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // ----- Old school Promise-style ----- // | |
| function nope (): Promise<never> { | |
| return Promise.reject('lol no') | |
| } | |
| // ----- Hipster async way ----- // | |
| async function asyncNope (): Promise<never> { | |
| throw 'lol no' | |
| } | |
| nope().catch(e => console.log('CAUGHT ERROR: ', e)) // CAUGHT ERROR: lol no | |
| asyncNope().catch(e => console.log('CAUGHT ERROR: ', e)) // CAUGHT ERROR: lol no |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment