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

217
Visualizações
How to catch child error from parent function

So guys I have 2 functions, the first is named child Function(), the second is parentFunction(). So I'm trying to get an error from childFunction(), where childFunction() contains the following code

async childFunction() {
  await getFromApi()
}

and i tried to call childFunction() from parentFunction() like this

async parentFunction() {
  try {
    await childFunction()
  } catch (e) {
    console.log(e)
  }
}

my expected error

Uncaught (in promise) TypeError: Failed to fetch
at fetchWith (fetch.browser.js?273a:103:1)
at Client.fetch (http.js?670b:132:1)
at Client.fetch (core.js?0abd:182:1)
at Client.post (http.js?670b:174:1)
at addAll (add-all.js?74f2:31:1)
at async last (index.js?9975:13:1)
at async Object.add (add.js?59bb:18:1)

but I don't get any error or console. So the error can only be accessed in childFunction() only when I use try-catch in childFunction(). Even then I can't send the error to parentFunction(). So my question, how to send error from childFunction() to parentFunction(). Thank you in advance

about 4 years ago · Juan Pablo Isaza
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