Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs-site/public/api/PuppeteerSharp.RemoteException.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="canonical" href="https://www.puppeteersharp.com/api/PuppeteerSharp/RemoteException/">
<meta http-equiv="refresh" content="0; url=/api/PuppeteerSharp/RemoteException/">
<title>Redirecting…</title>
<script>location.replace("/api/PuppeteerSharp/RemoteException/" + (location.hash || ""));</script>
</head>
<body>
<p><a href="/api/PuppeteerSharp/RemoteException/">Continue</a></p>
</body>
</html>
13 changes: 13 additions & 0 deletions docs-site/public/api/PuppeteerSharp.RemoteExceptionEventArgs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="canonical" href="https://www.puppeteersharp.com/api/PuppeteerSharp/RemoteExceptionEventArgs/">
<meta http-equiv="refresh" content="0; url=/api/PuppeteerSharp/RemoteExceptionEventArgs/">
<title>Redirecting…</title>
<script>location.replace("/api/PuppeteerSharp/RemoteExceptionEventArgs/" + (location.hash || ""));</script>
</head>
<body>
<p><a href="/api/PuppeteerSharp/RemoteExceptionEventArgs/">Continue</a></p>
</body>
</html>
403 changes: 215 additions & 188 deletions docs-site/src/content/docs/api/PuppeteerSharp/Page.md

Large diffs are not rendered by default.

133 changes: 133 additions & 0 deletions docs-site/src/content/docs/api/PuppeteerSharp/RemoteException.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
title: "RemoteException"
description: "A protocol-agnostic description of an uncaught exception thrown in a page or worker. Dispatched via the ExceptionThrown and ExceptionThrown events."
editUrl: false
prev: false
next: false
sidebar:
label: "RemoteException"
hidden: true
---

<a id="PuppeteerSharp_RemoteException"></a>

Namespace: [PuppeteerSharp](/api/PuppeteerSharp/)


```csharp
public class RemoteException
```


A protocol-agnostic description of an uncaught exception thrown in a page or worker.
Dispatched via the [ExceptionThrown](/api/PuppeteerSharp/IPage/#PuppeteerSharp_IPage_ExceptionThrown) and [ExceptionThrown](/api/PuppeteerSharp/WebWorker/#PuppeteerSharp_WebWorker_ExceptionThrown) events.

**Inheritance:** [object](https://learn.microsoft.com/dotnet/api/system.object)

Unlike the [PageError](/api/PuppeteerSharp/IPage/#PuppeteerSharp_IPage_PageError) event, [RemoteException](./) does not
reconstruct an error value. When the protocol supports it (CDP), it exposes the live remote
exception value through [Handle](#PuppeteerSharp_RemoteException_Handle). Each call frame of [StackTrace](#PuppeteerSharp_RemoteException_StackTrace) is reported as a
[ConsoleMessageLocation](/api/PuppeteerSharp/ConsoleMessageLocation/) (URL, line number and column number).

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/RemoteException.cs#L15)

## Properties

<a id="PuppeteerSharp_RemoteException_Handle_"></a>
<a id="PuppeteerSharp_RemoteException_Handle"></a>

### Handle


```csharp
public IJSHandle Handle { get; }
```


Gets the live remote exception value, if available. `null` for thrown primitives other than
symbols, for exceptions thrown in other isolated worlds, and for exceptions thrown by code that
Puppeteer injected.

**Value:** [IJSHandle](/api/PuppeteerSharp/IJSHandle/)

The handle is disposed automatically right after the event has been dispatched. To keep using it
beyond the synchronous part of your handler, call [Move()](/api/PuppeteerSharp/IJSHandle/#PuppeteerSharp_IJSHandle_Move) synchronously inside
the handler and dispose of the handle yourself once you are done with it.
The handle is shared by all handlers of the event.

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/RemoteException.cs#L69)

<a id="PuppeteerSharp_RemoteException_Location_"></a>
<a id="PuppeteerSharp_RemoteException_Location"></a>

### Location


```csharp
public ConsoleMessageLocation Location { get; }
```


Gets the primary location where the exception occurred.
For runtime errors this is the first element of [StackTrace](#PuppeteerSharp_RemoteException_StackTrace). For compilation and
syntax errors (where [StackTrace](#PuppeteerSharp_RemoteException_StackTrace) is empty), it falls back to the top-level
coordinates reported for the exception.

**Value:** [ConsoleMessageLocation](/api/PuppeteerSharp/ConsoleMessageLocation/)

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/RemoteException.cs#L56)

<a id="PuppeteerSharp_RemoteException_Name_"></a>
<a id="PuppeteerSharp_RemoteException_Name"></a>

### Name


```csharp
public string Name { get; }
```


Gets the name of the exception, for example `Error`, `TypeError`, `SyntaxError` or `AbortError`.
Empty string if the thrown value is not an error, for example a primitive, a plain object or a symbol.

**Value:** [string](https://learn.microsoft.com/dotnet/api/system.string)

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/RemoteException.cs#L42)

<a id="PuppeteerSharp_RemoteException_StackTrace_"></a>
<a id="PuppeteerSharp_RemoteException_StackTrace"></a>

### StackTrace


```csharp
public IReadOnlyList<ConsoleMessageLocation> StackTrace { get; }
```


Gets the call frames on the stack at the time the exception was thrown, innermost first.
Empty for compilation and syntax errors.

**Value:** [IReadOnlyList&lt;ConsoleMessageLocation&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist-1)

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/RemoteException.cs#L48)

<a id="PuppeteerSharp_RemoteException_Text_"></a>
<a id="PuppeteerSharp_RemoteException_Text"></a>

### Text


```csharp
public string Text { get; }
```


Gets the text of the exception as rendered by the browser, for example `Error: boom`.
For errors this is `${name}: ${message}` (or just the name if the message is empty), without the stack.
For other thrown values it is their description, for example `Object` for a plain object.

**Value:** [string](https://learn.microsoft.com/dotnet/api/system.string)

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/RemoteException.cs#L36)
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
title: "RemoteExceptionEventArgs"
description: "Event arguments for uncaught exceptions thrown in a page or worker."
editUrl: false
prev: false
next: false
sidebar:
label: "RemoteExceptionEventArgs"
hidden: true
---

<a id="PuppeteerSharp_RemoteExceptionEventArgs"></a>

Namespace: [PuppeteerSharp](/api/PuppeteerSharp/)


```csharp
public class RemoteExceptionEventArgs : EventArgs
```


Event arguments for uncaught exceptions thrown in a page or worker.

**Inheritance:** [object](https://learn.microsoft.com/dotnet/api/system.object) → [EventArgs](https://learn.microsoft.com/dotnet/api/system.eventargs)

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/RemoteExceptionEventArgs.cs#L8)

## Constructors

<a id="PuppeteerSharp_RemoteExceptionEventArgs__ctor_"></a>
<a id="PuppeteerSharp_RemoteExceptionEventArgs__ctor_PuppeteerSharp_RemoteException_"></a>

### RemoteExceptionEventArgs(RemoteException)


```csharp
public RemoteExceptionEventArgs(RemoteException exception)
```


Initializes a new instance of the [RemoteExceptionEventArgs](./) class.

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `exception` | [RemoteException](/api/PuppeteerSharp/RemoteException/) | The exception. |

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/RemoteExceptionEventArgs.cs#L14)

## Properties

<a id="PuppeteerSharp_RemoteExceptionEventArgs_Exception_"></a>
<a id="PuppeteerSharp_RemoteExceptionEventArgs_Exception"></a>

### Exception


```csharp
public RemoteException Exception { get; }
```


Gets the exception.

**Value:** [RemoteException](/api/PuppeteerSharp/RemoteException/)

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/RemoteExceptionEventArgs.cs#L19)
35 changes: 27 additions & 8 deletions docs-site/src/content/docs/api/PuppeteerSharp/WebWorker.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The CDP session client the WebWorker belongs to.

**Value:** [ICDPSession](/api/PuppeteerSharp/ICDPSession/)

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L43)
[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L52)

<a id="PuppeteerSharp_WebWorker_Url_"></a>
<a id="PuppeteerSharp_WebWorker_Url"></a>
Expand All @@ -73,7 +73,7 @@ Gets the Worker URL.

**Value:** [string](https://learn.microsoft.com/dotnet/api/system.string) — Worker URL.

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L38)
[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L47)

## Events

Expand All @@ -93,6 +93,25 @@ Fired when the worker calls a console API method.

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L32)

<a id="PuppeteerSharp_WebWorker_ExceptionThrown"></a>

### ExceptionThrown


```csharp
public event EventHandler<RemoteExceptionEventArgs> ExceptionThrown
```


Fired when an uncaught exception happens within the worker. Contains a [RemoteException](/api/PuppeteerSharp/RemoteException/).

**Value:** [EventHandler&lt;RemoteExceptionEventArgs&gt;](https://learn.microsoft.com/dotnet/api/system.eventhandler-1)

The [Handle](/api/PuppeteerSharp/RemoteException/#PuppeteerSharp_RemoteException_Handle) of the exception is disposed right after the event has been
dispatched. Call [Move()](/api/PuppeteerSharp/IJSHandle/#PuppeteerSharp_IJSHandle_Move) on it synchronously inside the handler to keep it alive.

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L41)

## Methods

<a id="PuppeteerSharp_WebWorker_CloseAsync_"></a>
Expand All @@ -110,7 +129,7 @@ Closes the worker.

**Returns:** [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) — A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that completes when the worker is closed.

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L133)
[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L146)

<a id="PuppeteerSharp_WebWorker_EvaluateExpressionAsync_"></a>
<a id="PuppeteerSharp_WebWorker_EvaluateExpressionAsync__1_System_String_"></a>
Expand Down Expand Up @@ -141,7 +160,7 @@ Executes a script in browser context.

If the script, returns a Promise, then the method would wait for the promise to resolve and return its value.

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L60)
[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L73)

<a id="PuppeteerSharp_WebWorker_EvaluateExpressionHandleAsync_"></a>
<a id="PuppeteerSharp_WebWorker_EvaluateExpressionHandleAsync_System_String_"></a>
Expand All @@ -166,7 +185,7 @@ Executes a script in browser context.

If the script, returns a Promise, then the method would wait for the promise to resolve and return its value.

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L99)
[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L112)

<a id="PuppeteerSharp_WebWorker_EvaluateFunctionAsync_"></a>
<a id="PuppeteerSharp_WebWorker_EvaluateFunctionAsync_System_String_System_Object___"></a>
Expand All @@ -193,7 +212,7 @@ Executes a function in browser context.
If the script, returns a Promise, then the method would wait for the promise to resolve and return its value.
[IJSHandle](/api/PuppeteerSharp/IJSHandle/) instances can be passed as arguments.

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L73)
[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L86)

<a id="PuppeteerSharp_WebWorker_EvaluateFunctionAsync__1_System_String_System_Object___"></a>

Expand Down Expand Up @@ -225,7 +244,7 @@ Executes a function in the context.
If the script, returns a Promise, then the method would wait for the promise to resolve and return its value.
[IJSHandle](/api/PuppeteerSharp/IJSHandle/) instances can be passed as arguments.

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L87)
[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L100)

<a id="PuppeteerSharp_WebWorker_WaitForFunctionAsync_"></a>
<a id="PuppeteerSharp_WebWorker_WaitForFunctionAsync_System_String_PuppeteerSharp_WaitForFunctionOptions_System_Object___"></a>
Expand All @@ -251,4 +270,4 @@ evaluated in the worker's context.

**Returns:** [Task&lt;IJSHandle&gt;](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) — A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that resolves to a [IJSHandle](/api/PuppeteerSharp/IJSHandle/) of the truthy value returned by the function.

[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L110)
[View source](https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/WebWorker.cs#L123)
2 changes: 2 additions & 0 deletions docs-site/src/content/docs/api/PuppeteerSharp/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ Browser, page, frame, element, network, and launch APIs.
| [RecordOptions](/api/PuppeteerSharp/RecordOptions/) | Options for RecordAsync(RecordOptions). |
| [ReloadOptions](/api/PuppeteerSharp/ReloadOptions/) | Options for ReloadAsync(ReloadOptions). |
| [RemoteAddress](/api/PuppeteerSharp/RemoteAddress/) | Remote server address. |
| [RemoteException](/api/PuppeteerSharp/RemoteException/) | A protocol-agnostic description of an uncaught exception thrown in a page or worker. Dispatched via the ExceptionThrown and ExceptionThrown events. |
| [RemoteExceptionEventArgs](/api/PuppeteerSharp/RemoteExceptionEventArgs/) | Event arguments for uncaught exceptions thrown in a page or worker. |
| [Request&lt;TResponse&gt;](/api/PuppeteerSharp/Request-1/) | Supports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy. |
| [RequestEventArgs](/api/PuppeteerSharp/RequestEventArgs/) | Arguments used by IPage events. |
| [ResourceTiming](/api/PuppeteerSharp/ResourceTiming/) | Resource timing information as returned by the DevTools Network domain. |
Expand Down
4 changes: 4 additions & 0 deletions lib/PuppeteerSharp/IPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public interface IPage : IDisposable, IAsyncDisposable
/// <summary>
/// Raised when an uncaught exception happens within the page.
/// </summary>
/// <remarks>
/// Prefer <see cref="ExceptionThrown"/>, which exposes the exception as a <see cref="RemoteException"/>
/// (text, name, stack trace, location and a live handle to the thrown value) instead of a reconstructed error.
/// </remarks>
event EventHandler<PageErrorEventArgs> PageError;

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion lib/PuppeteerSharp/RemoteException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace PuppeteerSharp
/// <remarks>
/// Unlike the <see cref="IPage.PageError"/> event, <see cref="RemoteException"/> does not
/// reconstruct an error value. When the protocol supports it (CDP), it exposes the live remote
/// exception value through <see cref="Handle"/>.
/// exception value through <see cref="Handle"/>. Each call frame of <see cref="StackTrace"/> is reported as a
/// <see cref="ConsoleMessageLocation"/> (URL, line number and column number).
/// </remarks>
public class RemoteException
{
Expand Down
Loading