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

283
Vistas
How to assign const values in error catching code without deep nesting?

I have this situation

try {
  const foo = await Foo();
} catch (error) {
  console.error(error);
  throw error;
}

I have to do a fair amount of stuff with the foo variable.

Is there a way I can use the foo variable without ending up nested several layers deeper because of try/catch blocks like this? This standard pattern won't work because it's const (and I prefer it to be const):

let x;
try {
  x = await X():
} catch (error) {
  throw error;
}
console.log(x);
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