Skip to content

Commit 899e3e1

Browse files
committed
fixes
1 parent d39750f commit 899e3e1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

6-async/03-promise-chaining/article.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Promises chaining
33

4-
Let's return to the problem mentioned in the chapter <info:callbacks>:
4+
Let's return to the problem mentioned in the chapter <info:callbacks>.
55

66
- We have a sequence of asynchronous tasks to be done one after another. For instance, loading scripts.
77
- How to code it well?
@@ -617,12 +617,13 @@ What happens when an error is not handled? For instance, after the rethrow as in
617617
```js untrusted run refresh
618618
new Promise(function() {
619619
noSuchFunction(); // Error here (no such function)
620-
});
620+
}); // no .catch attached
621621
```
622622

623623
Or here:
624624

625625
```js untrusted run refresh
626+
// a chain of promises without .catch at the end
626627
new Promise(function() {
627628
throw new Error("Whoops!");
628629
}).then(function() {
@@ -634,9 +635,9 @@ new Promise(function() {
634635
});
635636
```
636637

637-
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".
638+
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".
638639

639-
In practice, that means that the code is bad. Indeed, how come that there's no error handling?
640+
In practice, that's usually because of the bad code. Indeed, how come that there's no error handling?
640641

641642
Most JavaScript engines track such situations and generate a global error in that case. We can see it in the console.
642643

0 commit comments

Comments
 (0)