Skip to content

Promises chaining #189

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 9 commits into from
Jun 10, 2020
Merged
12 changes: 7 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,22 @@
The short answer is: **no, they are not equal**:

The difference is that if an error happens in `f1`, then it is handled by `.catch` here:
La respuesta corta es: **no, no son iguales**:

La diferencia es que si ocurre un error en `f1`, entonces aqui es manejado por `.catch`:

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

...But not here:
...Pero no aquí:

```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`.
Esto se debe a que se pasa un error por la cadena y en la segunda pieza del código no hay una cadena debajo de `f1`.

En otras palabras, `.then` pasa los resultados/errores al siguiente `.then/catch`. Entonces, en el primer ejemplo, hay un `catch` debajo, y en el segundo no lo hay, por lo que el error no se maneja.

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.
4 changes: 2 additions & 2 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,6 +1,6 @@
# Promise: then versus catch
# Promesa: then versus catch

Are these code fragments equal? In other words, do they behave the same way in any circumstances, for any handler functions?
¿Son iguales estos fragmentos de código? En otras palabras, ¿se comportan de la misma manera en cualquier circunstancia, para cualquier función de controlador?

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