Merge pull request #919 from dragonwocky/patch-3

make wording clearer
This commit is contained in:
Ilya Kantor 2019-04-17 17:44:48 +03:00 committed by GitHub
commit 1f19fd8a5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -76,7 +76,7 @@ new Promise((resolve, reject) => {
The "invisible `try..catch`" around the executor automatically catches the error and treats it as a rejection.
That's so not only in the executor, but in handlers as well. If we `throw` inside a `.then` handler, that means a rejected promise, so the control jumps to the nearest error handler.
This happens not only in the executor, but in its handlers as well. If we `throw` inside a `.then` handler, that means a rejected promise, so the control jumps to the nearest error handler.
Here's an example:
@ -90,7 +90,7 @@ new Promise((resolve, reject) => {
}).catch(alert); // Error: Whoops!
```
That's so not only for `throw`, but for any errors, including programming errors as well:
This happens for all errors, not just those caused by the `throw` statement. For example, a programming error:
```js run
new Promise((resolve, reject) => {
@ -102,7 +102,7 @@ new Promise((resolve, reject) => {
}).catch(alert); // ReferenceError: blabla is not defined
```
As a side effect, the final `.catch` not only catches explicit rejections, but also occasional errors in the handlers above.
The final `.catch` not only catches explicit rejections, but also occasional errors in the handlers above.
## Rethrowing
@ -120,7 +120,7 @@ new Promise((resolve, reject) => {
throw new Error("Whoops!");
}).catch(function(error) {
}).catch(function(error) {
alert("The error is handled, continue normally");