我的 Express 应用程序中的一个常见模式是在我的所有路线中包含以下内容:
//...code which could result in an err
if (!err) return res.send(200);
console.log(err); // Would prefer to omit this line
res.send(500);
现在,我需要写下console.log(err)我所有的路线。我宁愿在err每次发送 500 时自动记录变量。有没有办法连接到 Express 并自动记录调用堆栈和/或err所有 500 个响应?