Skip to main content

WebError

WebError class represents an unhandled exception thrown in the page. It is dispatched via the BrowserContext.onWebError(handler) event.

// Log all uncaught errors to the terminal
context.onWebError(webError -> {
System.out.println("Uncaught exception: " + webError.error());
});

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

Methods

error

Added in: v1.38 webError.error

Unhandled error that was thrown.

Usage

WebError.error();

Returns


location

Added in: v1.60 webError.location

Usage

WebError.location();

Returns

  • Location#
    • url String

      URL of the resource.

    • line int

      0-based line number in the resource.

    • column int

      0-based column number in the resource.


page

Added in: v1.38 webError.page

The page that produced this unhandled exception, if any.

Usage

WebError.page();

Returns