Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

293
Vistas
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 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda