Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Practice Error Handling in Express!
You have completed Practice Error Handling in Express!
Preview
This video covers one solution to the error handling challenge.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
challenging aspects of
server-side development.
0:00
Here's how I went about
completing the exercise.
0:00
First, the 404 handler in app.js.
0:03
I set the HTTP status for the response to
404 and rendered the not-found template.
0:07
Next, right below in
the global error handler,
0:14
I created an if statement to check for
the error status.
0:17
if (err.status === 404),
I set the res.status to 404 and
0:21
rendered the not-found template,
passing it the err object.
0:26
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up