node/test/parallel/test-process-exception-capture-should-abort-on-uncaught-setflagsfromstring.js
Anna Henningsen 4503da8a3a
process: add flag for uncaught exception abort
Introduce `process.shouldAbortOnUncaughtException` to control
`--abort-on-uncaught-exception` behaviour, and implement
some of the domains functionality on top of it.

PR-URL: https://github.com/nodejs/node/pull/17159
Refs: https://github.com/nodejs/node/issues/17143
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
2017-11-29 15:58:42 +01:00

14 lines
460 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const v8 = require('v8');
assert.strictEqual(process.hasUncaughtExceptionCaptureCallback(), false);
v8.setFlagsFromString('--abort-on-uncaught-exception');
// This should make the process not crash even though the flag was passed.
process.setUncaughtExceptionCaptureCallback(common.mustCall((err) => {
assert.strictEqual(err.message, 'foo');
}));
throw new Error('foo');