process: Add --unhandled-rejections=throw and =warn-with-error-code
This PR defines two new modes for the --unhandled-rejections flag.
The first mode is called "throw". The "throw" mode first emits unhandledRejection. If this hook is not set, the "throw" mode will raise the unhandled rejection as an uncaught exception.
The second mode is called "warn-with-error-code". The "warn-with-error-code" mode first emits unhandledRejection. If this hook is not set, the "warn-with-error-code" mode will trigger a warning and set the process's exit code to 1.
The PR doesn't change the default behavior for unhandled rejections. That will come in a separate PR.
Refs: https://github.com/nodejs/node/pull/33021
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines