diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-11 22:46:43 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-04-15 19:29:07 +0300 |
commit | 9dcc9b6a6b3b8ab40be91b2fdc6fdf514e48dcc3 (patch) | |
tree | b715c7140d05728acc5237d12b22eee7e2d0caff /src/node_errors.cc | |
parent | 2755471bf3ce35a14cb348d4fbf0d34779426e66 (diff) |
process: add --unhandled-rejections flag
This adds a flag to define the default behavior for unhandled
rejections. Three modes exist: `none`, `warn` and `strict`. The first
is going to silence all unhandled rejection warnings. The second
behaves identical to the current default with the excetion that no
deprecation warning will be printed and the last is going to throw
an error for each unhandled rejection, just as regular exceptions do.
It is possible to intercept those with the `uncaughtException` hook
as with all other exceptions as well.
This PR has no influence on the existing `unhandledRejection` hook.
If that is used, it will continue to function as before.
PR-URL: https://github.com/nodejs/node/pull/26599
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'src/node_errors.cc')
-rw-r--r-- | src/node_errors.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/node_errors.cc b/src/node_errors.cc index 3c041529743..83dbfc611fe 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -10,6 +10,7 @@ namespace node { using errors::TryCatchScope; +using v8::Boolean; using v8::Context; using v8::Exception; using v8::Function; @@ -771,7 +772,8 @@ void DecorateErrorStack(Environment* env, void FatalException(Isolate* isolate, Local<Value> error, - Local<Message> message) { + Local<Message> message, + bool from_promise) { CHECK(!error.IsEmpty()); HandleScope scope(isolate); @@ -794,9 +796,12 @@ void FatalException(Isolate* isolate, // Do not call FatalException when _fatalException handler throws fatal_try_catch.SetVerbose(false); + Local<Value> argv[2] = { error, + Boolean::New(env->isolate(), from_promise) }; + // This will return true if the JS layer handled it, false otherwise MaybeLocal<Value> caught = fatal_exception_function.As<Function>()->Call( - env->context(), process_object, 1, &error); + env->context(), process_object, arraysize(argv), argv); if (fatal_try_catch.HasTerminated()) return; @@ -821,4 +826,10 @@ void FatalException(Isolate* isolate, } } +void FatalException(Isolate* isolate, + Local<Value> error, + Local<Message> message) { + FatalException(isolate, error, message, false /* from_promise */); +} + } // namespace node |