Skip to main content

WebError

WebError 类表示页面中抛出的未处理异常。它通过 browser_context.on("weberror") 事件分发。

# Log all uncaught errors to the terminal
context.on("weberror", lambda web_error: print(f"uncaught exception: {web_error.error}"))

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

属性

🌐 Properties

error

Added in: v1.38 webError.error

引发的未处理错误。

🌐 Unhandled error that was thrown.

用法

web_error.error

返回


page

Added in: v1.38 webError.page

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

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

用法

web_error.page

返回