express 基本样本

示例

与其他中间件函数不同,错误处理中间件函数具有四个参数,而不是三个:(err, req, res, next)。

样品:

app.use(function(err, req, res, next) {
  console.error(err.stack);
  res.status(500).send('Error found!');
});