Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

292
Visualizações
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 Respostas
Responde à pergunta

0

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

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda