I have tried:
app.get('/', function(req, res, next) {
var e = new Error('error message');
e.status = 400;
next(e);
});
and:
app.get('/', function(req, res, next) {
res.statusCode = 400;
var e = new Error('error message');
next(e);
});
but always an error code of 500 is announced.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…