Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ddc5532
zlib: port errors to new system
targos Feb 27, 2018
def3846
vm: port errors to new system
targos Feb 27, 2018
c0d20ba
v8: port errors to new system
targos Feb 27, 2018
b08cf46
util: port errors to new system
targos Feb 27, 2018
4a314e7
url: port errors to new system
targos Feb 27, 2018
247ddb8
tty: port errors to new system
targos Feb 27, 2018
870cdf0
tls: port: errors to new system
targos Feb 27, 2018
a7aa7bd
timers: port errors to new system
targos Feb 27, 2018
f350861
string_decoder: port errors to new system
targos Feb 27, 2018
82a4d20
repl: port errors to new system
targos Feb 27, 2018
fa70791
readline: port errors to new system
targos Feb 27, 2018
721314e
querystring: port errors to new system
targos Feb 27, 2018
a7df2bc
perf_hooks: port errors to new system
targos Feb 27, 2018
bda8874
path: port errors to new system
targos Feb 27, 2018
530f289
net: port errors to new system
targos Feb 27, 2018
ac2c9c3
module: port errors to new system
targos Feb 27, 2018
d102090
inspector: port errors to new system
targos Feb 27, 2018
0db60be
https: port errors to new system
targos Feb 27, 2018
a6b8a25
fs: port errors to new system
targos Feb 27, 2018
0b226fd
events: port errors to new system
targos Feb 27, 2018
ee6945c
domain: port errors to new system
targos Feb 27, 2018
5eaffd2
dns: port errors to new system
targos Feb 27, 2018
eabb4f6
dgram: port errors to new system
targos Feb 27, 2018
7d14db2
crypto: port errors to new system
targos Feb 27, 2018
e78c0f9
child_process: port errors to new system
targos Feb 27, 2018
bee022b
buffer: port errors to new system
targos Feb 27, 2018
eccd4b0
async_hooks: port errors to new system
targos Feb 27, 2018
dbddf7b
assert: port errors to new system
targos Feb 27, 2018
0d5b4b9
FIXUP: linter
targos Mar 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
domain: port errors to new system
  • Loading branch information
targos committed Mar 4, 2018
commit ee6945ce067e31ecd5a8abd424089072a017818d
13 changes: 8 additions & 5 deletions lib/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@

const util = require('util');
const EventEmitter = require('events');
const errors = require('internal/errors');
const {
ERR_DOMAIN_CALLBACK_NOT_AVAILABLE,
ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE,
ERR_UNHANDLED_ERROR
} = require('internal/errors').codes;
const { createHook } = require('async_hooks');

// overwrite process.domain with a getter/setter that will allow for more
Expand Down Expand Up @@ -80,16 +84,15 @@ const asyncHook = createHook({
// When domains are in use, they claim full ownership of the
// uncaught exception capture callback.
if (process.hasUncaughtExceptionCaptureCallback()) {
throw new errors.Error('ERR_DOMAIN_CALLBACK_NOT_AVAILABLE');
throw new ERR_DOMAIN_CALLBACK_NOT_AVAILABLE();
}

// Get the stack trace at the point where `domain` was required.
const domainRequireStack = new Error('require(`domain`) at this point').stack;

const { setUncaughtExceptionCaptureCallback } = process;
process.setUncaughtExceptionCaptureCallback = function(fn) {
const err =
new errors.Error('ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE');
const err = new ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE();
err.stack = err.stack + '\n' + '-'.repeat(40) + '\n' + domainRequireStack;
throw err;
};
Expand Down Expand Up @@ -439,7 +442,7 @@ EventEmitter.prototype.emit = function emit(...args) {

if (type === 'error') {
const er = args.length > 1 && args[1] ?
args[1] : new errors.Error('ERR_UNHANDLED_ERROR');
args[1] : new ERR_UNHANDLED_ERROR();

if (typeof er === 'object') {
er.domainEmitter = this;
Expand Down