Skip to content

Promises chaining #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions 1-js/11-async/03-promise-chaining/01-then-vs-catch/solution.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
The short answer is: **no, they are not the equal**:
La réponse courte est: **non, ils ne sont pas égaux**:

The difference is that if an error happens in `f1`, then it is handled by `.catch` here:
La différence est que si une erreur survient dans `f1`, elle est gérée par` .catch` ici:

```js run
promise
.then(f1)
.catch(f2);
```

...But not here:
...Mais pas ici:

```js run
promise
.then(f1, f2);
```

That's because an error is passed down the chain, and in the second code piece there's no chain below `f1`.
En effet, une erreur est transmise dans la chaîne et, dans le second code, il n'y a pas de chaîne à la suite de `f1`.

In other words, `.then` passes results/errors to the next `.then/catch`. So in the first example, there's a `catch` below, and in the second one -- there isn't, so the error is unhandled.
En d'autres termes, `.then` transmet les résultats/erreurs au prochain `.then/catch`. Donc, dans le premier exemple, il y a un `catch` en dessous, et dans le second - il n'y en a pas, donc l'erreur n'est pas gérée.
6 changes: 3 additions & 3 deletions 1-js/11-async/03-promise-chaining/01-then-vs-catch/task.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Promise: then versus catch
# Promesse: then contre catch

Are these code fragments equal? In other words, do they behave the same way in any circumstances, for any handler functions?
Ces fragments de code sont-ils égaux? En d'autres termes, se comportent-ils de la même manière en toutes circonstances, pour toutes les fonctions gestionnaires?

```js
promise.then(f1).catch(f2);
```

Versus:
Contre:

```js
promise.then(f1, f2);
Expand Down
Loading