◐ Shell
reader mode source ↗
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
4 changes: 2 additions & 2 deletions 1-js/11-async/04-promise-error-handling/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Dans un `try...catch` classique nous pouvons analyser l'erreur et peut-être la

Si nous utilisons `throw` dans `.catch`, alors le contrôle passe au gestionnaire d'erreur suivant qui est plus proche. Et si nous gérons l'erreur et finissons normalement, alors elle continue jusqu'au gestionnaire `.then` le plus proche.

In the example below the `.catch` successfully handles the error:

```js run
// l'exécution: catch -> then
Expand Down Expand Up @@ -149,7 +149,7 @@ new Promise((resolve, reject) => {
});
```

The execution jumps from the first `.catch` `(*)` to the next one `(**)` down the chain.

## Rejets non traités

Expand Down
12 changes: 6 additions & 6 deletions 1-js/11-async/05-promise-api/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,15 @@ La première promesse a été la plus rapide, donc, elle est devenue le résulta

## Promise.any

Similar to `Promise.race`, but waits only for the first fulfilled promise and gets its result. If all of the given promises are rejected, then the returned promise is rejected with [`AggregateError`](mdn:js/AggregateError) - a special error object that stores all promise errors in its `errors` property.

The syntax is:

```js
let promise = Promise.any(iterable);
```

For instance, here the result will be `1`:

```js run
Promise.any([
Expand All @@ -237,9 +237,9 @@ Promise.any([
]).then(alert); // 1
```

The first promise here was fastest, but it was rejected, so the second promise became the result. After the first fulfilled promise "wins the race", all further results are ignored.

Here's an example when all promises fail:

```js run
Promise.any([
Expand All @@ -252,7 +252,7 @@ Promise.any([
});
```

As you can see, error objects for failed promises are available in the `errors` property of the `AggregateError` object.

## Promise.resolve/reject

Expand Down
Toggle all file notes Toggle all file annotations