Skip to main content

class: WebError

Added in: v1.38

WebError class represents an unhandled exception thrown in the page. It is dispatched via the BrowserContext.event('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​

Added in: v1.38 Returns: null|Page

The page that produced this unhandled exception, if any.

method: WebError.error​

Added in: v1.38 Returns: Error

Unhandled error that was thrown.

method: WebError.error​

Added in: v1.38

Languages: Java, C# Returns: string

Unhandled error that was thrown.