Skip to content

Instantly share code, notes, and snippets.

@HenriqueSilverio
Last active January 28, 2021 13:34
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 HenriqueSilverio/851d644dad6fb2b9deeb1d0429cb881e to your computer and use it in GitHub Desktop.
Save HenriqueSilverio/851d644dad6fb2b9deeb1d0429cb881e to your computer and use it in GitHub Desktop.
const start = async () => {
throw new Error('Failed to start!')
}
start()
.catch(async err => {
// Precisa de async no catch pra fazer upload de alguma coisa por exemplo...
// Mas por ser async, pode por sua vez dar erro também...
// Então throw novamente...
throw new Error('Failed to catch start error!')
})
.catch(err => {
// Se deu erro no start e o primeiro catch falhou por algum motivo...
// Encerra aqui de forma síncrona...
console.error('Some unhandled error happened!')
console.error(err.stack)
process.exit(1)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment