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

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