Skip to content

Commit b2305ce

Browse files
authored
Merge pull request #1550 from hrodward/patch-22
Update article.md
2 parents 7fcd048 + ccccf10 commit b2305ce

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

1-js/11-async/04-promise-error-handling/article.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ new Promise(function() {
166166

167167
In case of an error, the promise becomes rejected, and the execution should jump to the closest rejection handler. But there is none. So the error gets "stuck". There's no code to handle it.
168168

169-
In practice, just like with regular unhandled errors in code, it means that something has terribly gone wrong.
169+
In practice, just like with regular unhandled errors in code, it means that something has gone terribly wrong.
170170

171-
What happens when a regular error occurs and is not caught by `try..catch`? The script dies with a message in console. Similar thing happens with unhandled promise rejections.
171+
What happens when a regular error occurs and is not caught by `try..catch`? The script dies with a message in the console. A similar thing happens with unhandled promise rejections.
172172

173-
JavaScript engine tracks such rejections and generates a global error in that case. You can see it in the console if you run the example above.
173+
The JavaScript engine tracks such rejections and generates a global error in that case. You can see it in the console if you run the example above.
174174

175175
In the browser we can catch such errors using the event `unhandledrejection`:
176176

@@ -201,4 +201,4 @@ In non-browser environments like Node.js there are other ways to track unhandled
201201
- `.catch` handles errors in promises of all kinds: be it a `reject()` call, or an error thrown in a handler.
202202
- We should place `.catch` exactly in places where we want to handle errors and know how to handle them. The handler should analyze errors (custom error classes help) and rethrow unknown ones (maybe they are programming mistakes).
203203
- It's ok not to use `.catch` at all, if there's no way to recover from an error.
204-
- In any case we should have the `unhandledrejection` event handler (for browsers, and analogs for other environments), to track unhandled errors and inform the user (and probably our server) about the them, so that our app never "just dies".
204+
- In any case we should have the `unhandledrejection` event handler (for browsers, and analogs for other environments) to track unhandled errors and inform the user (and probably our server) about them, so that our app never "just dies".

0 commit comments

Comments
 (0)