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 REST APIs with Express!
You have completed REST APIs with Express!
Preview
A lot can go wrong in an application, and a big part of a developer’s job is to account for and gracefully deal with a variety of errors. We'll write a global error handler to send error messages to the client as JSON.
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
account for and
gracefully deal with a variety of errors.
0:00
We're already doing a decent job of that,
but
0:03
there are some things we can do that will
cut down on some of our repeating code.
0:05
There are two basic types of
errors we're dealing with,
0:09
stuff that went wrong with the request,
and stuff that went wrong with the server.
0:12
We're currently addressing
errors that occur, for
0:17
example, if the client makes a request
to a quote id that doesn't exist.
0:19
But look what happens when we
request a route that doesn't exist.
0:23
Go to post man and
0:27
send a request to local host slash
3,000 followed by some gibberish.
0:28
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