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

108
Views
Where should I handle errors? Inside function itself or where I call it?

What is the best practice for handling errors in JavaScript?

I have a errorMan function which takes care of errors and prevents my NodeJS app from breaking. Where should I use this function to catch errors?

Scenario #1

async function helperFunc() {
  try {
    // Do some async requests
  } catch (error) {
    // returns false
    errorMan({error, path:__filename, name:"helperFunc"});
  }
}


async function bar() {
  const get = await helperFunc();
  if(!get) return;
}

Scenario #2

async function helperFunc() {
    // Do some async requests and return
}


async function bar() {
  try {
    const get = await helperFunc();
  } catch (error) {
    // Can't get real path and exact function name
    errorMan({error, path:__filename, name:"?"});
  }
}
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!