Skip to content

Instantly share code, notes, and snippets.

@jdelibas
Created May 3, 2017 07:46
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 jdelibas/0ddaf539d42699474378816b794e5a47 to your computer and use it in GitHub Desktop.
Save jdelibas/0ddaf539d42699474378816b794e5a47 to your computer and use it in GitHub Desktop.
async error test
async function runFn (q) {
try {
if (q === 1) {
throw q
}
return q
} catch (e) {
throw e
}
}
setTimeout(() => {
runFn(1)
.then(res => {
console.log('res')
console.log(res)
})
.catch(err => {
console.log('err')
console.log(err)
})
}, 1000)
runFn(2)
.then(res => {
console.log('res')
console.log(res)
})
.catch(err => {
console.log('err')
console.log(err)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment