I am using node express (4.15.2), with the default express generator function to handle errors.
The code is:
// error handler
app.use(function(err, req, res, next) {
// this function is never called
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
In my application I using the following line of code when I need to create an error:
new Error('Some custom error');
But the error handler is never called.
Notes: the error handler is placed after the latest app.use but before app.listen.
Any ideas what could cause this issue and how to fix it?
via GibboK
No comments:
Post a Comment