diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-11 20:46:43 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-04-15 18:29:07 +0200 |
commit | 9dcc9b6a6b3b8ab40be91b2fdc6fdf514e48dcc3 (patch) | |
tree | b715c7140d05728acc5237d12b22eee7e2d0caff /src/node_options.cc | |
parent | 2755471bf3ce35a14cb348d4fbf0d34779426e66 (diff) | |
download | android-node-v8-9dcc9b6a6b3b8ab40be91b2fdc6fdf514e48dcc3.tar.gz android-node-v8-9dcc9b6a6b3b8ab40be91b2fdc6fdf514e48dcc3.tar.bz2 android-node-v8-9dcc9b6a6b3b8ab40be91b2fdc6fdf514e48dcc3.zip |
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_options.cc')
-rw-r--r-- | src/node_options.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/node_options.cc b/src/node_options.cc index c307c66a62..cb490dad75 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -141,6 +141,13 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) { errors->push_back("invalid value for --http-parser"); } + if (!unhandled_rejections.empty() && + unhandled_rejections != "strict" && + unhandled_rejections != "warn" && + unhandled_rejections != "none") { + errors->push_back("invalid value for --unhandled-rejections"); + } + #if HAVE_INSPECTOR debug_options_.CheckOptions(errors); #endif // HAVE_INSPECTOR @@ -287,6 +294,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { "custom loader", &EnvironmentOptions::userland_loader, kAllowedInEnvironment); + AddOption("--entry-type", + "set module type name of the entry point", + &EnvironmentOptions::module_type, + kAllowedInEnvironment); AddOption("--es-module-specifier-resolution", "Select extension resolution algorithm for es modules; " "either 'explicit' (default) or 'node'", @@ -342,9 +353,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { "show stack traces on process warnings", &EnvironmentOptions::trace_warnings, kAllowedInEnvironment); - AddOption("--entry-type", - "set module type name of the entry point", - &EnvironmentOptions::module_type, + AddOption("--unhandled-rejections", + "define unhandled rejections behavior. Options are 'strict' (raise " + "an error), 'warn' (enforce warnings) or 'none' (silence warnings)", + &EnvironmentOptions::unhandled_rejections, kAllowedInEnvironment); AddOption("--check", |