Writing below code, I am expecting that error occurred during server starting or starting of listening will be catched in the catch block.
const HTTP = require("http");
try {
HTTP.
createServer((request, response) => {
console.log(request);
console.log(response);
}).
listen(3000, () => { console.log("started") });
} catch (error) {
console.error(error);
}
Actually, it did not happen. For example, if execute two instances of above file, the second one will crush with
Error: listen EADDRINUSE: address already in use :::3000