Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Node.js Basics 2017 Handling Errors in Node Handling Status Code Errors

Vincent Wang
Vincent Wang
1,976 Points

Redundant try-catch block?

In this video, if we already implemented a try-catch block for a parsing exception which would be thrown if there is an invalid JSON object, does this become redundant now that we have this error message for an unexpected https response, since when we look for an invalid profile it should return 404, and it won't bother with the parsing try-catch block

2 Answers

Steven Parker
Steven Parker
231,261 Points

These are different kinds of errors.

For example, what if your request was for a valid profile, but due to some internal error the server returned an invalid JSON object?

Vincent Wang
Vincent Wang
1,976 Points

I see, that makes sense thank you!

Christopher Debove
PLUS
Christopher Debove
Courses Plus Student 18,373 Points

Asynchronous flow's errors are not caught by the external try-catch.