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 trialAakash Srivastava
5,415 PointsHandling Status Codes Error
In the previous video , Chalkley included the try catch statement inside the
response.on('end', () => {......}
block in case case user enters the wrong profile name or profile doesn't exist , it will handle the error.
Now , when he put the condition i,e if (response.statusCode === 200)
to handle the same error i,e if profile not found , is it still necessary to write that try catch statement written inside the block `response.on('end', () => {......}
.
I think , try catch doesn't do anything now as , if profile will not be found , that if else
statement will handle those before it will reach to the try catch
May be i am getting wrong . Need help
1 Answer
<noob />
17,062 PointsHe wasn't handilng profile not foudn error, he is handling what happend if u get a different response.statusCode rather than 200.