summaryrefslogtreecommitdiff
path: root/test/parallel/test-process-exception-capture-errors.js
blob: 8eb825267cf336f89bb59827c76f21933c33f8d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'use strict';
const common = require('../common');
const assert = require('assert');

assert.throws(
  () => process.setUncaughtExceptionCaptureCallback(42),
  {
    code: 'ERR_INVALID_ARG_TYPE',
    name: 'TypeError',
    message: 'The "fn" argument must be of type function or null. ' +
             'Received type number (42)'
  }
);

process.setUncaughtExceptionCaptureCallback(common.mustNotCall());

assert.throws(
  () => process.setUncaughtExceptionCaptureCallback(common.mustNotCall()),
  {
    code: 'ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET',
    name: 'Error',
    message: /setupUncaughtExceptionCapture.*called while a capture callback/
  }
);