0
app.use(function(err,res,req,next){
});
將致力於服務器響應之前,只有當誤差,但如果誤差是res.send
後此功能將不會被執行。 我該如何解決這個問題?
app.use(function(err,res,req,next){
});
將致力於服務器響應之前,只有當誤差,但如果誤差是res.send
後此功能將不會被執行。 我該如何解決這個問題?
它被在Express 4的執行:
app.use(function(req, res, next) {
res.send('foo');
throw new Error('bar'); // or `next(new Error('bar'))`
});
app.use(function(err, req, res, next) {
console.log('err', err);
});
此返回響應和記錄錯誤。
生成/傳遞的錯誤究竟如何? – robertklep