server.on("request", function(req, res) {
var file = fs.createReadStream(req.url || "index.html");
...
}
file.on("error", function(err) {
console.log(err);
});
var file = fs.createReadStream("somefilethatnotexist.html");
file.on("error", (err) => {
console.log('I got error!');
});
server.on("error", (err) => {
console.log('I got error!');
});