Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

396
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!