// [3] ERROR SECT. const errorHandler = (error) => { if (error.syscall !== "listen") { throw error; } const address = server.address(); const bind = typeof address === "string" ? "pipe " + address : "port: " + port; switch (error.code) { case "EACCES": console.error(bind + " requires elevated privileges."); process.exit(1); break; case "EADDRINUSE": console.error(bind + " is already in use."); process.exit(1); break; default: throw error; } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter