I am following book 'Node.js In Action' one earlier access version from http://www.manning.com/cantelon/ and the author uses method 'error()' on 'res' object in section about Express. So, the following code that copied from book:
exports.required = function(field){
field = parseField(field);
return function(req, res, next){
if (getField(req,field)){
next()
} else {
res.error(field.join(' ') + ' is required');
...
However, this breaks with the error:
TypeError: Object #<ServerResponse> has no method 'error'
From Node.js docs, i see there is no method for response object. I wonder if there is a middlware that decorates 'res' object with the missing method error() that i need to include. Here is the current configurations:
app.configure(function(){
app.set('port', process.env.PORT || 3001);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.set('photos', __dirname + '/public/photos');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.cookieSession());
app.use(user);
app.use(app.router);
app.use(express.errorHandler());
});
If there is none, but you know how to decorate the response object with method error(), I would appreciate if you could share the code snippet for it. thank you