JavaScript Node.js Basics Handling Errors in Node Handling Errors in Node

Marina Emmatty
Marina Emmatty
620 Points

my Task 1 fails when i try to run task 3

am i putting try and catch at wrong place?

const https = require("https");
try {

const request=https.get("", response => {

request.on('error',error=>console.error('problem with request:${error.message}'));


1 Answer

Steven Parker
Steven Parker
203,722 Points

You don't need a try or catch for this challenge.

The instructions for task 3 are: "Finally, in the error callback, use the error method on the console to print out the error message."

So you can leave off the try and the entire catch block. But then there's still a few issues:

  • an interpolated string should be enclosed with accents, not apostrophes
  • the challenge isn't prepared to evaluate the output with an additional string added anyway
  • apparently either the on method or the "check work" mechanism rely on the arguments object
  • no arguments object is created when the "arrow" function notation is used, use the conventional notation instead