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

211
Views
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
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!