docs/src/api/class-weberror.md
[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);
};
The page that produced this unhandled exception, if any.
Unhandled error that was thrown.
Unhandled error that was thrown.