Skip to main content

WebError

WebError 类表示页面中抛出的未处理的异常。它是通过 browserContext.on('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.

用法

¥Usage

webError.error();

返回

¥Returns


page

Added in: v1.38 webError.page

产生此未处理异常的页面(如果有)。

¥The page that produced this unhandled exception, if any.

用法

¥Usage

webError.page();

返回

¥Returns