code: function(err, req, res, next) {
      if (err) {
          var url = req.url || '';
  
          log.debug(req.method, req.headers);
          log.error(('Requested url: ' + url).red, ('Error: ' + err.stack).red);
  
          if (req.xhr) {
              res.status(500).json({msg: 'Server error'});
          } else {
              res.status(500).send('Server error');
          }
      } else {
          next();
      }
  }
docs: /* /Serving content /* Error handling