title: Node.js Express app handle startup errors
body: <p>I have app in Node.js and Express. I need to write tests for it. I have a problem with handling Express app errors. I found this <a href="https://stackoverflow.com/questions/9544479/how-do-i-catch-node-js-express-server-errors-like-eaddrinuse">How do I catch node.js/express server errors like EADDRINUSE?</a>, but it doesn't work for me, I don't know why. I want to handle errors, which can occured while expressApp.listen() is executing (EADDRINUSE, EACCES etc.).</p>
  
  <pre><code>express = require('express')
  listener = express()
  
  #doesn't work for me
  listener.on('uncaughtException', (err) -&gt;
    #do something
  )
  
  #doesn't work too
  listener.on("error", (err) -&gt;
    #do something
  )
  
  #this works, but it caughts all errors in process, I want only in listener
  process.on('uncaughtException', (err) -&gt;
    #do something
  )
  
  listener.listen(80) #for example 80 to get error
  </code></pre>
  
  <p>Any ideas?</p>