How does express under node locate the error.jade file

  node.js, question

I am using the default environmentexpress nodeTest
Open the app.js file in the directory. Lines 29 to 33:

clipboard.png

app.use(function(req, res, next) {
 var err = new Error('Not Found');
 err.status = 404;
 next(err);
 });

While error.jade is in the views directory inside under the root directory.
App.use has only been assigned here, and I don’t see any other operations.
How did he determine the error.jade file called by the use?
So as to achieve, input the wrong path, call error.jade to render the page

app.use(function(req, res, next) {
 var err = new Error('Not Found');
 err.status = 404;
 next(err);
 });

There is a next parameter in the above code, which is a function that represents entering the next matching route, while there is a code below app.js that reads like this, I’ll post it to you

app.use(function(err, req, res, next) {
 res.status(err.status || 500);
 res.render('error', {
 message: err.message,
 error: {}
 });
 });

The first parameter of app.use is path path. When there is no match/,all routes that have not returned will pass through here. The next function transfers the request to the next route that matches the matching path. When next(err) finally passes through the above route, it renders error.jade.