Playwright.WebError (Playwright v1.65.0-rc.3)

Copy Markdown View Source

WebError class represents an unhandled exception thrown in the page. It is dispatched via the BrowserContext.on(:web_error) event.

# Log all uncaught errors to the terminal
BrowserContext.on(context, :web_error, fn web_error ->
  IO.puts(~s(Uncaught exception: "#{Exception.message(WebError.error(web_error))}"))
end)

# Navigate to a page with an exception.
Page.goto!(page, ~s{data:text/html,<script>throw new Error("Test")</script>})

Since Playwright 1.38.

The examples alias the modules they use (alias Playwright.{Locator, Page}).

Summary

Types

t()

A WebError handle. Compare handles with ==, their fields are internal.

Functions

Unhandled error that was thrown.

Since Playwright 1.60.

The page that produced this unhandled exception, if any.

Types

t()

@type t() :: %Playwright.WebError{_error: term(), _location: term(), _page: term()}

A WebError handle. Compare handles with ==, their fields are internal.

Functions

error(web_error)

@spec error(t()) :: Exception.t()

Unhandled error that was thrown.

Since Playwright 1.38.

location(web_error)

@spec location(t()) :: %{url: String.t(), line: integer(), column: integer()}

Since Playwright 1.60.

page(web_error)

@spec page(t()) :: nil | Playwright.Page.t()

The page that produced this unhandled exception, if any.

Since Playwright 1.38.