@@ -263,6 +263,31 @@ void v8_init() {
263
263
V8::Initialize ();
264
264
}
265
265
266
+ /*
267
+ bool AbortOnUncaughtExceptionCallback(Isolate* isolate) {
268
+ return true;
269
+ }
270
+
271
+ void MessageCallback2(Local<Message> message, Local<Value> data) {
272
+ printf("MessageCallback2\n\n");
273
+ }
274
+
275
+ void FatalErrorCallback2(const char* location, const char* message) {
276
+ printf("FatalErrorCallback2\n");
277
+ }
278
+ */
279
+
280
+ void ExitOnPromiseRejectCallback (PromiseRejectMessage message) {
281
+ auto exception = message.GetValue ();
282
+
283
+ auto isolate = Isolate::GetCurrent ();
284
+ auto m = Exception::CreateMessage (isolate, exception );
285
+
286
+ printf (" Unhandled Promise\n " );
287
+ m->PrintCurrentStackTrace (isolate, stdout);
288
+ exit (1 );
289
+ }
290
+
266
291
worker* worker_new (int table_index) {
267
292
worker* w = new (worker);
268
293
@@ -275,7 +300,13 @@ worker* worker_new(int table_index) {
275
300
HandleScope handle_scope (isolate);
276
301
277
302
w->isolate = isolate;
278
- w->isolate ->SetCaptureStackTraceForUncaughtExceptions (true );
303
+ // Leaving this code here because it will probably be useful later on, but
304
+ // disabling it now as I haven't got tests for the desired behavior.
305
+ // w->isolate->SetCaptureStackTraceForUncaughtExceptions(true);
306
+ // w->isolate->SetAbortOnUncaughtExceptionCallback(AbortOnUncaughtExceptionCallback);
307
+ // w->isolate->AddMessageListener(MessageCallback2);
308
+ // w->isolate->SetFatalErrorHandler(FatalErrorCallback2);
309
+ w->isolate ->SetPromiseRejectCallback (ExitOnPromiseRejectCallback);
279
310
w->isolate ->SetData (0 , w);
280
311
w->table_index = table_index;
281
312
0 commit comments