-
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathErrorEvents.h
More file actions
56 lines (50 loc) · 2.88 KB
/
Copy pathErrorEvents.h
File metadata and controls
56 lines (50 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef ErrorEvents_h
#define ErrorEvents_h
#include <string>
#include "Common.h"
namespace tns {
class ErrorEvents {
public:
// Installs the WHATWG error-events layer on top of the generic event
// primitives: the ErrorEvent and PromiseRejectionEvent constructors
// (subclassing the Event installed by Events::Init, captured off globalThis
// at init time) and global reportError. Evaluated once per isolate during
// Runtime::Init, right after Events::Init, for both main and worker isolates.
// The bootstrap IIFE is invoked with the backing event target
// (Caches->GlobalEventTarget) and the native nativeReportFatal(error, stack)
// function, and returns three closures bound to the internal listener store;
// they are stashed in Caches so native dispatch survives app code overwriting
// globalThis.dispatchEvent.
static void Init(v8::Local<v8::Context> context);
// Dispatches the cancelable `error` ErrorEvent through the JS listener store.
// Returns true when a listener called preventDefault(). A dispatch that
// itself throws is logged and treated as unprevented so an error is never
// lost.
static bool DispatchError(v8::Isolate* isolate, v8::Local<v8::Value> error,
const std::string& messageString,
const std::string& stack);
// Dispatches the cancelable `unhandledrejection` PromiseRejectionEvent
// through the JS listener store. Returns true when a listener called
// preventDefault(). Never re-dispatches on failure: a dispatch that itself
// throws is logged and treated as unprevented so the error is never lost.
static bool DispatchUnhandledRejection(v8::Isolate* isolate,
v8::Local<v8::Promise> promise,
v8::Local<v8::Value> reason);
// Fires the non-cancelable `rejectionhandled` PromiseRejectionEvent for a
// late-attached handler, carrying the original rejection reason.
static void DispatchRejectionHandled(v8::Isolate* isolate,
v8::Local<v8::Promise> promise,
v8::Local<v8::Value> reason);
// Fires the cancelable `releasednativeaccess` event: JS touched a wrapper
// whose native counterpart was already released while the
// `releasedObjectPolicy` runtime config (ns:runtime) is "report". `error`
// carries the stack captured at the touch site; `operation` names the API
// surface. The debug console warning is the event's default action, so a
// listener that handles the report suppresses it with preventDefault().
// A dispatch that throws is swallowed after logging.
static void DispatchReleasedNativeAccess(v8::Isolate* isolate,
v8::Local<v8::Value> error,
const std::string& operation);
};
} // namespace tns
#endif /* ErrorEvents_h */