跳转到主要内容

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>")

属性

error

新增于: v1.38 webError.error

被抛出的未处理错误。

用法

web_error.error

返回


location

添加于: v1.60 webError.location

用法

web_error.location

返回

  • Dict#
    • url str

      资源的 URL。

    • line int

      资源中从 0 开始的行号。

    • column int

      资源中从 0 开始的列号。


page

新增于: v1.38 webError.page

如果存在,生成此未处理异常的页面。

用法

web_error.page

返回