From 899e3e17de2edb76733e827a7207075476b5cd26 Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Thu, 28 Sep 2017 01:14:52 +0300 Subject: [PATCH] fixes --- 6-async/03-promise-chaining/article.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/6-async/03-promise-chaining/article.md b/6-async/03-promise-chaining/article.md index 41acc387..e59365fc 100644 --- a/6-async/03-promise-chaining/article.md +++ b/6-async/03-promise-chaining/article.md @@ -1,7 +1,7 @@ # Promises chaining -Let's return to the problem mentioned in the chapter : +Let's return to the problem mentioned in the chapter . - We have a sequence of asynchronous tasks to be done one after another. For instance, loading scripts. - How to code it well? @@ -617,12 +617,13 @@ What happens when an error is not handled? For instance, after the rethrow as in ```js untrusted run refresh new Promise(function() { noSuchFunction(); // Error here (no such function) -}); +}); // no .catch attached ``` Or here: ```js untrusted run refresh +// a chain of promises without .catch at the end new Promise(function() { throw new Error("Whoops!"); }).then(function() { @@ -634,9 +635,9 @@ new Promise(function() { }); ``` -In theory, nothing should happen. In case of an error happens, the promise state becomes "rejected", and the execution should jump to the closest rejection handler. But there is no such handler in the examples above. So the error gets "stuck". +In case of an error, the promise state becomes "rejected", and the execution should jump to the closest rejection handler. But there is no such handler in the examples above. So the error gets "stuck". -In practice, that means that the code is bad. Indeed, how come that there's no error handling? +In practice, that's usually because of the bad code. Indeed, how come that there's no error handling? Most JavaScript engines track such situations and generate a global error in that case. We can see it in the console.