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 trialEllis Corio
22,035 Pointscan anyone tell me what is wrong with this error handler?
request.on('error', error => console.error(Problem with request: ${error.message}
));
4 Answers
Ga In Shin
9,930 Pointshey Ellis, I had the same problem, and found the solution in the node.js document.
You have to put your error handler on the outside of the whole get() method as such:
https.get('https://encrypted.google.com/', (res) => {
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers);
res.on('data', (d) => {
process.stdout.write(d);
});
}).on('error', (e) => {
console.error(e);
});
Chris Jones
Java Web Development Techdegree Graduate 23,933 PointsAre you getting any output when the program runs? Or is the error handler just not being executed?
Ellis Corio
22,035 Pointsi am getting an out put yes:
but it s the same message i would be getting without the error handler
Ellis Corio
22,035 Pointsi actually went into the next workspace where the teacher had left his finished code, i copy/pasted and over wrote my own code, was pretty much identical anyway, and still........the error handlers do not seem to work
Chris Jones
Java Web Development Techdegree Graduate 23,933 PointsHi Ellis, can you share the link to your workspace?
Ellis Corio
22,035 PointsEllis Corio
22,035 Pointsthe back ticks are there they just dont want to copy for some reason