Skip to content

Instantly share code, notes, and snippets.

@aherve
Last active December 7, 2016 13:36
Show Gist options
  • Select an option

  • Save aherve/1ccfa53b640222193c8bfacb2f2b0509 to your computer and use it in GitHub Desktop.

Select an option

Save aherve/1ccfa53b640222193c8bfacb2f2b0509 to your computer and use it in GitHub Desktop.
// ----- 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