diff --git a/1-js/11-async/02-promise-basics/article.md b/1-js/11-async/02-promise-basics/article.md index f2f533220e..ba2ae5893b 100644 --- a/1-js/11-async/02-promise-basics/article.md +++ b/1-js/11-async/02-promise-basics/article.md @@ -242,7 +242,7 @@ That said, `finally(f)` isn't exactly an alias of `then(f,f)` though. There are For instance, here the result is passed through `finally` to `then`: ```js run new Promise((resolve, reject) => { - setTimeout(() => resolve("result"), 2000) + setTimeout(() => resolve("result"), 2000); }) .finally(() => alert("Promise ready")) .then(result => alert(result)); // <-- .then handles the result @@ -260,6 +260,18 @@ That said, `finally(f)` isn't exactly an alias of `then(f,f)` though. There are That's very convenient, because `finally` is not meant to process a promise result. So it passes it through. + However, if `finally` throws an error, that promise will be rejected with that value instead. + + ```js run + new Promise((resolve, reject) => { + setTimeout(() => resolve("result"), 1000); + }) + *!* + .finally(() => { throw new Error("error"); }) + */!* + .catch((err) => alert(err)); // <-- .catch handles the error object + ``` + We'll talk more about promise chaining and result-passing between handlers in the next chapter.