From the course: Building a Website with Node.js and Express.js

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Populating the error page

Populating the error page

From the course: Building a Website with Node.js and Express.js

Start my 1-month free trial

Populating the error page

- [Instructor] As you might have figured, this is still not dynamic because that's still a static page so we will now have to apply our template variables so I go back into the error template and in there I will just add my template text so 4404 I replace that with bracket percent equal status and for the message I'll put the error message. So let's head back into the browser, let's reload the page. As you see now we get this proper error message and when we go back to the index route that contains another error we get 500 and some error, so the error message that we defined before. What I'm not showing here is the actual error stack trace as we saw it before because it's a pretty bad practice to show that to the user because it may contain sensitive information so what we can do instead is we can go into the error handler again and just add a console.error I'll put the error to the console so that when we look into log file we see…

Contents