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

213
Vistas
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 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