Error handling with promises by diogoosz · Pull Request #467 · javascript-tutorial/pt.javascript.info
Repository navigation
Error handling with promises - #467
Merged
gabifs merged 2 commits into javascript-tutorial:master from diogoosz:translate-promise-error-handling Nov 8, 2026
Merged
Error handling with promises #467 gabifs merged 2 commits into javascript-tutorial:master from diogoosz:translate-promise-error-handling
Conversation
diogoosz commented Nov 7, 2026
Copy link Copy Markdown
Contributor
Tradução do artigo "Error handling with promises" para o português, incluindo o exercício.
Conforme comentado na #1 .
Translate 'Error handling with promises' article to Portuguese
d4be610
gabifs
mentioned this pull request
Nov 7, 2026
Portuguese Translation Progress
#1
Open
gabifs
reviewed
Nov 7, 2026
View reviewed changes
Comment thread 1-js/11-async/04-promise-error-handling/article.md
Outdated
| .then(() => { | ||
| // successful promise handlers, one or more | ||
| }); // without .catch at the end ! | ||
| // tratadores de promessa bem-sucedidos, um ou mais |
Outdated
| ## try..catch implícito | ||
|
|
||
| The code of a promise executor and promise handlers has an "invisible ` try..catch `" around it. If an exception happens, it gets caught and treated as a rejection . | ||
| O código de um executor de promessa e dos tratadores de promessa tem um " try..catch invisível" ao redor dele. Se uma exceção acontece, ela é capturada e tratada como uma rejeição . |
Outdated
| ``` | ||
|
|
||
| The "invisible ` try..catch `" around the executor automatically catches the error and turns it into rejected promise . | ||
| O " try..catch invisível" ao redor do executor captura o erro automaticamente e o transforma em uma promessa rejeitada . |
Outdated
| ``` | ||
|
|
||
| As said in the chapter, there's an "implicit ` try..catch `" around the function code. So all synchronous errors are handled . | ||
| Como dito no capítulo, existe um " try..catch implícito" ao redor do código da função. Então todos os erros síncronos são tratados . |
Outdated
| - O `.then` também captura erros da mesma forma, se receber o segundo argumento (que é o tratador de erro ). | ||
| - Devemos colocar o `.catch` exatamente nos lugares onde queremos tratar erros e sabemos como tratá-los. O tratador deve analisar os erros (classes de erro personalizadas ajudam) e relançar os desconhecidos (talvez sejam erros de programação ). | ||
| - Não tem problema não usar `.catch` de jeito nenhum, se não houver como se recuperar de um erro . | ||
| - Em qualquer caso, devemos ter o tratador do evento `unhandledrejection` (para navegadores, e equivalentes para outros ambientes) para rastrear erros não tratados e informar o usuário (e provavelmente nosso servidor) sobre eles, para que nosso app nunca "simplesmente morra ". |
Outdated
| Em um `try..catch` normal, podemos analisar o erro e talvez relançá-lo se não puder ser tratado. A mesma coisa é possível com promessas . | ||
|
|
||
| If we `throw` inside `.catch`, then the control goes to the next closest error handler. And if we handle the error and finish normally, then it continues to the next closest successful `.then` handler . | ||
| Se dermos um `throw` dentro do `.catch`, o controle vai para o próximo tratador de erro mais próximo. E se tratarmos o erro e terminarmos normalmente, então ele continua para o próximo tratador `.then` de sucesso mais próximo . |
Outdated
|
|
||
| if (error instanceof URIError) { | ||
| // handle it | ||
| // trata isso |
Apply review suggestions from gabifs
e42f325
diogoosz commented Nov 8, 2026
Copy link Copy Markdown
Contributor
Author
|
Obrigado, @gabifs ! Apliquei tudo: corrigi o sentido de "successful promise handlers" (tratadores de sucesso, não tratadores bem-sucedidos), devolvi as crases em |
46f93f7
into
javascript-tutorial : master
Nov 8, 2026
1 check passed
Sign up for free
to join this conversation on GitHub .
Already have an account?
Sign in to comment