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 Parsing and Status Code Errors

Paul Milbank
Paul Milbank
6,445 Points

Am I right in saying this should actually be a 404 as the error is not with missing 'http://' but wwwteamtreehouse.com?

failure says "Actually, this is a connection error. URLs start with "http://". A server response wouldn't even be triggered."

2 Answers

andren
andren
28,558 Points

The reason given for why it would trigger a connection error is wrong, as it has nothing to do with the protocol. But it is correct that the code would trigger a connection error.

A 404 error occurs when you connect to a server an request a resource that the server cannot find. However in the case of "https://wwwteamtreehouse.com/chalkers.json" there is no website with the URL "wwwteamtreehouse.com" so you won't end up contacting a server at all.

Since no server is reached you don't end up initiating a HTTP connection, so no HTTP error codes or anything like that will be generated.

Paul Milbank
Paul Milbank
6,445 Points

Good point, thanks very much. skipped my mind that 404 is a server response code so it it doesn't connect, it won't give a 404.