title: How do I catch node.js/express server errors like EADDRINUSE?
body: <p>This is my code.</p>
  
  <pre><code>if !module.parent
      try
          hons_server.listen config.port
          console.log 'Listening to port ' + config.port
      catch err
          console.error "Couldn't start server: #{String(err)}".red
  </code></pre>
  
  <p><code>hons_server</code> is an <a href="http://expressjs.com/guide.html#creating-a%20server" rel="noreferrer">express.js server</a>. I'm having a hard time understanding why errors thrown as a result of <code>hons_server.listen()</code> aren't caught by the try/catch. When I run my server twice I get the output:</p>
  
  <pre>
  $ coffee src/server.coffee
  Listening to port 9090
  
  node.js:201
          throw e; // process.nextTick error, or 'error' event on first tick
                ^
  Error: listen EADDRINUSE
      at errnoException (net.js:632:11)
      at Array.0 (net.js:733:26)
      at EventEmitter._tickCallback (node.js:192:40)
  </pre>
  
  <p>I'd like to know why the thrown error isn't caught, and how/where I can catch the EADDRINUSE error.</p>