Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

297
Views
Funtion generator does not throw an error that is catched by another function

So I was playing with Redux-Saga when came to a error handling stuff. The problem is that the function generator has try catch block and it calls getAllUserColivings function. This function catches the error Request failed with status code 404. I did that on purpose (messed up url). However, the generator does not catched any errors and done success function which is not great.

Here is the generator code (yes, I know that JWT token should not be in localStorage, but it is for now)

  try {
    const jwtToken = yield localStorage.getItem("jwt");
    const colivings = yield getAllUserColivings(jwtToken);
    yield console.log(colivings, "coliving");
    yield put(updateColivingsSuccess(colivings));
  } catch (error) {
    yield put(updateColivingsFailure(error));
  }
}

Here is the getAllUserColivings function code:

  try {
    const validation = await getUserIDByJWT(jwt);
    let formData = new FormData();
    formData.append("strapi_id", validation);
    const response = await axios.post(
      "http://localhost:8000/includes/settings/colivins.php",
      formData,
      headers
    );
    return response.data;
  } catch (error) {
    return console.log(error.message);
  }
};```
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You should be returning the whole error, not console.log function.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!