Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda