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

115
Vistas
try/catch within catch block is not executing

I have written nested try/catch block like below.

static async myEx(){
  return 'hello';
}

static async myfunc() {

try{
  Logger.info('test1');
} catch(error){
  Logger.info('test2');
  try{
    Logger.info('test3');
    return await this.myEx();
  }catch(error2){
    Logger.info('test4');
  }
}
 return null;
}

myfunc();

when I run the code,I have got following as the output.

 test2

That means second try/catch block is not executed. I want to execute myEX() function within the second try block. Can someone help me to resolve the issue?

Output that I want:

test2  
test3
hello
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

async function myEx() {
    console.log('hello');
}

async function myfunc() {
    try {
        throw new Error();
        console.log('test1');
    } catch (error) {
        console.log('test2');
        try {
            console.log('test3');
            return await myEx();
        } catch (error2) {
            console.log('test4');
        }
    }
    return null;
}

myfunc();

about 4 years ago · Juan Pablo Isaza Denunciar
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