You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/11-async/04-promise-error-handling/article.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -199,6 +199,7 @@ In non-browser environments like Node.js there are other ways to track unhandled
199
199
## Summary
200
200
201
201
-`.catch` handles errors in promises of all kinds: be it a `reject()` call, or an error thrown in a handler.
202
+
-`.then` also catches errors in the same manner, if given thee second argument (which is the error handler).
202
203
- 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).
203
204
- It's ok not to use `.catch` at all, if there's no way to recover from an error.
204
205
- 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