mirror of
https://github.com/nodejs/node.git
synced 2025-05-14 16:35:53 +00:00

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 PR-URL: https://github.com/nodejs/node/pull/33475 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
11 lines
274 B
JavaScript
11 lines
274 B
JavaScript
// Flags: --unhandled-rejections=warn-with-error-code
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
common.disableCrashOnUnhandledRejection();
|
|
|
|
Promise.reject(new Error('alas'));
|
|
process.on('exit', assert.strictEqual.bind(null, 1));
|