Skip to content

Instantly share code, notes, and snippets.

@dkstevekwak
Created March 7, 2018 16:20
Show Gist options
  • Select an option

  • Save dkstevekwak/0c3a25c8091e736dee0b71f604a85c5d to your computer and use it in GitHub Desktop.

Select an option

Save dkstevekwak/0c3a25c8091e736dee0b71f604a85c5d to your computer and use it in GitHub Desktop.
/* Catching errors in promisified functions */
runEvalScript('firstFunction()')
.then(function(firstResult){
return runEvalScript(`secondFunction(${firstResult})`)
})
.catch(function(error) {
//handle any error that may occur in firstFunction()
}
.then(function(secondResult){
return runEvalScript(`thirdFunction(${secondResult})`)
})
.then(function(thirdResult){
// more promises..!
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment