Skip to content

Latest commit

 

History

History
67 lines (51 loc) · 1.71 KB

class-weberror.md

File metadata and controls

67 lines (51 loc) · 1.71 KB

class: WebError

  • since: v1.38

[WebError] class represents an unhandled exception thrown in the page. It is dispatched via the [event: BrowserContext.webError] event.

// Log all uncaught errors to the terminal
context.on('weberror', webError => {
  console.log(`Uncaught exception: "${webError.error()}"`);
});

// Navigate to a page with an exception.
await page.goto('data:text/html,<script>throw new Error("Test")</script>');
// 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>");
# 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.
await page.goto("data:text/html,<script>throw new Error('test')</script>")
# 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>")
// Log all uncaught errors to the terminal
context.WebError += (_, webError) =>
{
  Console.WriteLine("Uncaught exception: " + webError.Error);
};

method: WebError.page

  • since: v1.38
  • returns: <[null]|[Page]>

The page that produced this unhandled exception, if any.

method: WebError.error

  • since: v1.38
  • returns: <[Error]>

Unhandled error that was thrown.

method: WebError.error

  • since: v1.38
  • langs: java, csharp
  • returns: <[string]>

Unhandled error that was thrown.