# `PlaywrightEx.WebError`
[🔗](https://github.com/ftes/playwright_ex/blob/v0.17.0-rc.5/lib/playwright_ex/api/web_error.ex#L3)

[`WebError`](`PlaywrightEx.WebError`) class represents an unhandled exception thrown in the page. It is dispatched via the [`BrowserContext.on(:web_error)`](PlaywrightEx.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 PlaywrightEx.{Locator, Page}`).

# `t`

```elixir
@type t() :: %PlaywrightEx.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 | PlaywrightEx.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*
