So I have this pageerror event handler catching an error, and it's working fine. But if I wanted more details from the stacktrace, I'm not sure how to do it.
Here's what I've written so far
(context: reportStatus is a function that sends a status report to an API endpoint and prints to console as well. It takes the title of the status, and a callback function)
pupPage.on('pageerror', async (error) => {
console.log("ERROR'd");
console.log(Object.getOwnPropertyNames(Object.getPrototypeOf(error)));
reportStatus('WEB_APPLICATION_ERROR', async function () {
var stackTrace;
utl.print('Error message: ' + error);
// GET THE STACKTRACE THAT CAUSED THE ERROR AND PRINT IT!
quit();
});
});
And this is what I see in the console.
ERROR'd
[ 'constructor', 'name', 'message', 'toString' ]
WEB_APPLICATION_ERROR
Error message: ReferenceError: params is not defined
QUITTING
So I know that the error is a ReferenceError where some "params" variable is not defined. But I want to know more details, like what line in what script caused that error.
Unfortunately, it doesn't seem like the error
object has anything related to the stacktrace.
Is there a function I could use to get the stacktrace of the error that triggered the pageerror
event?