I have tried:
app.get(\'/\', function(req, res, next) { var e = new Error(\'error message\'); e.status = 400; next(e); });
and:
Old question, but still coming up on Google. In the current version of Express (3.4.0), you can alter res.statusCode before calling next(err):
res.statusCode = 404; next(new Error('File not found'));