# `Playwright.WebError`
[🔗](https://github.com/ftes/playwright_ex/blob/v1.65.0-rc.3/lib/playwright/api/web_error.ex#L7)

[`WebError`](`Playwright.WebError`) class represents an unhandled exception thrown in the page. It is dispatched via the [`BrowserContext.on(:web_error)`](Playwright.BrowserContext.html#module-web_error) event.

```elixir
# 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}`).

# `t`

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

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

# `error`

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

Unhandled error that was thrown.

*Since Playwright 1.38.*

# `location`

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

*Since Playwright 1.60.*

# `page`

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

The page that produced this unhandled exception, if any.

*Since Playwright 1.38.*

---

*Consult [api-reference.md](api-reference.md) for complete listing*
