1'use strict';
2
3const common = require('../common');
4const domain = require('domain');
5
6function test() {
7  const d = domain.create();
8  const d2 = domain.create();
9
10  d.on('error', function errorHandler() {
11  });
12
13  d.run(() => {
14    d2.run(() => {
15      const fs = require('fs');
16      fs.exists('/non/existing/file', function onExists() {
17        throw new Error('boom!');
18      });
19    });
20  });
21}
22
23if (process.argv[2] === 'child') {
24  test();
25} else {
26  common.childShouldThrowAndAbort();
27}
28