Errors are already addressed in Express for you. In the app.js
file, there is the following:
/// catch 404 and forwarding to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
Then in the views/
dir, there is errors.jade
.
extends layout
block content
h1= message
h2= error.status
pre #{error.stack}
Simple. If you want to customize your 404 page, simply edit this view.