AsynchronousLesson 13Free preview
Node Errors Handling
This lesson is part of Node.js · All levels
Summary
It provides a variety of strategies for handling errors, from callback error-first, try/catch to Promise, to the uncaughtException handler as the final safety net. The best practice is to handle the error as close as possible to the source and always check the status of the HTTP response. That way, one failure doesn't instantly crash the whole process. (Node.js)
Key points
- Use try/catch on the await code to capture runtime error
- Always check the fetch before processing the body response
- Set process.on('uncaughtException') as the last safety net
- UnhandledRejection marks a promise that fails without handling the catch
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.