Listen to res.sendFile errors in Express
<p>I have this simple code</p>

<pre><code>router.post('/foo', function(req,res,next){
    try{
      var file = path.resolve(folder, runId, 'temp.html');
      res.sendFile(file);
    }
    catch(err{
      //not reached
      next(err);
    }
});
</code></pre>

<p>the file I am trying to send does not exist, which is a possible but fine exception. However, res.sendFile does not throw synchronous errors.</p>

<p>It doesn't appear that I can listen for errors this way:</p>

<p><code>res.sendFile(file).on('error', function(){})</code> // ?</p>

<p>So how can we handle errors thrown by res.sendFile?</p>