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

387
Visualizações
Is there a way just replace with custom error each async error message without try catch each function?

let say launch method if executable not found it will throw, the error throw with string type. why it not object { message: 'Error failed', additionalInfo: 'trouble', executablePath: 'c:/' }. it happen to almost puppeteer method. so i need to replace it.

Error: Failed to launch the browser process! spawn H:/WebGame/GoogleChrome/chromess.exe ENOENT TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

instead, below ways.

class CustomError extends Error {
    constructor(executablePath) {
    super()
     this.message = 'Error: Failed to launch the browser process!';
     this.executablePath = executablePath;
  }
}

class Application {
  constructor() {
    this.browser;
  }
  async launch(options) {
    try {
      this.browser = await puppeteer.launch();
      return this.browser
    } catch(e) { throw new CustomError(options.executablePath) }
  }

  async close() await this.browser.close()
}

theres simply to just replace the error?

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