Error Handling in Node.js
Node.js applications require solid and consistent control over errors. Most applications are built using many dependencies or heavily rely on asynchronous operations (network, disk, and so on), which makes error management more complex.
In this chapter, we will learn about the different types of errors that we can encounter in a Node.js application and how to handle them properly. We will also learn how to throw custom errors and how to capture and resume the application from any kind of error, including the ones that occur in Express applications.
We will also learn how to manage a graceful shutdown when the service crashes, how to use exit codes according to the situation, and how to prevent zombie processes.
To sum up, here are the main topics that we will explore in this chapter:
- How to throw custom errors
- How to capture and recover from any kind of error
- How to manage application and user errors in Express
- How to manage a...