Last active
January 28, 2021 13:34
-
-
Save HenriqueSilverio/851d644dad6fb2b9deeb1d0429cb881e to your computer and use it in GitHub Desktop.
This file contains 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
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