Occasionally, when I run my puppeteer script, I’ll get a “page crashed” error. It’s most likely not a software error, but something to do with the proxy IPs I’m using/webpages I’m scraping. So all I’m really looking to do is just catch the error, close the current page, and open up a new page.
However, my try catch block doesn’t seem to be working. My code is structured like this:
try {
//puppeteer code
}
catch(e) {
console.log(‘caught error ‘ + e);
}
But when the page crashed error happens, I see “unhandled promise rejection error” instead of my console.log message. What’s going on here?
e.messageto only print the message. 2) please provide more detailed code, do you have any code outside of try/catch block? 3) have you tried calling it onerrorevent? e.g.page.on('error', msg => throw msg)newPage()and beforegoto()await page.goto('example.com').catch(function (error) { throw new Error('this error happend'); });