title: Pug Error Handling for a NodeJS, Express and Pug based Application
body: <p>I'm using Node.js, Express and Pug to create a simple Webserver.</p>
  
  <p>package.json:</p>
  
  <pre><code>{
    "name": "testing",
    "version": "0.0.7",
    "private": true,
    "scripts": {
      "start": "node ./bin/www"
    },
    "dependencies": {
      "body-parser": "~1.17.1",
      "command-line-args": "^4.0.6",
      "cookie-parser": "~1.4.3",
      "debug": "~2.6.3",
      "express": "~4.15.2",
      "less-middleware": "~2.2.0",
      "merge": "^1.2.0",
      "morgan": "~1.8.1",
      "pug": "^2.0.0-rc.2",
      "request": "^2.81.0",
      "serve-favicon": "~2.4.2",
      "sprintf-js": "^1.1.1",
      "tracer": "^0.8.9"
    }
  }
  </code></pre>
  
  <p>The server is started with the start command:</p>
  
  <pre><code>npm start
  </code></pre>
  
  <p>When the app contains errors like calling a non existing pug mixin:</p>
  
  <pre><code>.container
      +hossa
  </code></pre>
  
  <p>an error text is rendered and shows up in the client browser like so:</p>
  
  <pre><code>/Projects/.../status.pug:2 1| .container &gt; 2| +hossa 3| 4| 5| div.page.container.hidden#status(text="Status") pug_mixins.hossa is not a function
  </code></pre>
  
  <p>which is ok, but could be improved.</p>
  
  <p>The main problem: I see no error in the log output other than a 500 code.</p>
  
  <p>The questions are:</p>
  
  <ul>
  <li>what code, modul, and/or startup options are needed to log the error including the full stack information on the server side?</li>
  <li>How do I manage it to render some more user friendly message?</li>
  </ul>