Skip to main content

WebError

WebError class represents an unhandled exception thrown in the page. It is dispatched via the browserContext.on('weberror') event.

// Log all uncaught errors to the terminal
context.on('weberror', webError => {
console.log(`Uncaught exception: "${webError.error()}"`);
});

// Navigate to a page with an exception.
await page.goto('data:text/html,<script>throw new Error("Test")</script>');

方法 (Methods)

error

Added in: v1.38 webError.error

Unhandled error that was thrown.

使用方式

webError.error();

傳回值


page

Added in: v1.38 webError.page

The page that produced this unhandled exception, if any.

使用方式

webError.page();

傳回值