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 Express Basics!
You have completed Express Basics!
Preview
Build a custom error middleware function into the app.
Documentation
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
This is done with a special
type of middleware.
0:00
While Express middleware has three
parameters, error middleware has four.
0:02
It's the same signature
as normal middleware but
0:07
an extra parameter at the beginning.
0:10
That's where Express will pass
the error object to itself.
0:13
When an object is passed
into the next call,
0:18
Express jumps to the first middleware
it can find, with four parameters.
0:21
So far,
we don't have any of those in our app.
0:27
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