Table of Contents

Class PromiseRejectionEvent

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The PromiseRejectionEvent interface represents events which are sent to the global script context when JavaScript Promises are rejected. These events are particularly useful for telemetry and debugging purposes.

[Value("PromiseRejectionEvent")]
public class PromiseRejectionEvent : Event
Inheritance
PromiseRejectionEvent
Inherited Members

Remarks

For details, see Promise rejection events.

-Using promises
-Promise
-Windowrejectionhandled
-Windowunhandledrejection

See also on MDN

Constructors

PromiseRejectionEvent()

public PromiseRejectionEvent()

PromiseRejectionEvent(string, PromiseRejectionEventInit)

The PromiseRejectionEvent()
constructor returns a new PromiseRejectionEvent object, which
represents events fired when a JavaScript Promise is rejected.

public PromiseRejectionEvent(string type, PromiseRejectionEventInit eventInitDict)

Parameters

type string
eventInitDict PromiseRejectionEventInit

Remarks

With promise rejection events, it becomes possible to detect and report promises which
fail and whose failures go unnoticed. It also becomes easier to write a global handler
for errors.

There are two types of PromiseRejectionEvent:
Window.Unhandledrejection is sent by the JavaScript runtime when a promise is
rejected but the rejection goes unhandled. A Window.Rejectionhandled event is
emitted if a promise is rejected but the rejection is caught by a rejection handler.

-Using promises
-Promise
-PromiseRejectionEvent

See also on MDN

Properties

Promise

The PromiseRejectionEvent interface's
promise read-only property indicates the JavaScript
Promise which was rejected. You can examine the event's
Reason property to learn why the promise was
rejected.

[Value("promise")]
public Object Promise { get; }

Property Value

Object

The JavaScript Promise which was rejected, and whose rejection went
unhandled.

Remarks

-Promise rejection events
-Promise
-PromiseRejectionEvent
-Window.Rejectionhandled
-Window.Unhandledrejection

See also on MDN

Reason

The PromiseRejectionEvent reason read-only
property is any JavaScript value or Object which provides the reason
passed into PromiseReject. This in theory provides information about
why the promise was rejected.

[Value("reason")]
public dynamic Reason { get; }

Property Value

dynamic

A value or object which provides information you can use to understand why the promise
was rejected. This could be anything from an error code to an object with text, links,
and whatever else you might wish to include.

Remarks

-Promise
-PromiseRejectionEvent
-Window.Rejectionhandled
-Window.Unhandledrejection

See also on MDN