HTTP 요청의 오류를 처리하는 방법은 무엇입니까?http 요청에서 express.js 오류 처리
다음은 전체 오류 어떻게 로그에 오류를 작성하고 클라이언트에 Fatal error
을 반환 .. 클라이언트에 반환됩니다?
익스프레스 v4.4.4
var express = require('express'),
app = express(),
domain = require('domain'),
port = 3000;
app.use(function(err, req, res, next){
console.error(err.stack);
res.send('Fatal error!', 500);
});
app.get('/', function(req, res){
var d = domain.create();
d.on('error', function(err){
console.error('Error', err);
res.send('Fatal error!', 500);
});
d.add(req);
d.add(res);
d.run(function(){
// a is undefined
a.ddd();
res.send('Success!');
});
})
.listen(port, function(){
console.log('Express server listening on port '+port);
});
http://expressjs.com/guide.html#error-handling –
업데이트 한 대신 오류 메시지를 반환하는 다음 (오류)를 호출 Stack to the client – clarkk
친구 - 'app.use'가 그 예입니다. –