Now that your server is talking to the world and you can see what’s going on there, we have another important topic to discuss—errors.
Due to the single-threaded nature of Node.js and the lack of default configuration, a single error could bring the entire application crashing down, something we definitely don’t want.
Error handling has been left in the hands of the programmers, and because of the nature of Node.js, it’s somewhat complicated to implement correctly.
Let’s investigate the various ways to address error handling in Node.js. There are several layers of implementation, and the best one to use would depend on the scale and nature of the application.
First, we want to prevent ...