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

160
Views
JS: are inner try/catches necessary?

exported js helpers file

export const foo1 = async () =>  {
    const url = "www.foo.com";

    try {
        response = await fetch(url, { method: 'POST'});
    } catch (e) {
        throw new Error(`return another error:${e}`);
    }

    if (response) {
        const responseText = await response.text();

        const blob = responseText.toBlob();
        return blob;
    }
}

main js file

If I import the foo1 function in here and put it in a try/catch:

try {
   this.fooData = await foo1();
} catch(e) {
   this.error = e
}

can I remove the try/catch from foo1's fetch? Is it now unncessary since I have one in the main function that is invoking foo1?

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!