Skip to content

Commit

Permalink
dgram,process,util: refactor Error to TypeError
Browse files Browse the repository at this point in the history
PR-URL: nodejs#13857
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
  • Loading branch information
BridgeAR authored and tniessen committed Jun 28, 2017
1 parent 1698c8e commit 1a452f1
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function newHandle(type) {
return handle;
}

throw new errors.Error('ERR_SOCKET_BAD_TYPE');
throw new errors.TypeError('ERR_SOCKET_BAD_TYPE');
}


Expand Down
2 changes: 1 addition & 1 deletion lib/internal/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function setupKillAndExit() {
if (lazyConstants()[sig]) {
err = process._kill(pid, lazyConstants()[sig]);
} else {
throw new errors.Error('ERR_UNKNOWN_SIGNAL', `${sig}`);
throw new errors.TypeError('ERR_UNKNOWN_SIGNAL', sig);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function convertToValidSignal(signal) {
if (signalName) return signalName;
}

throw new errors.Error('ERR_UNKNOWN_SIGNAL', signal);
throw new errors.TypeError('ERR_UNKNOWN_SIGNAL', signal);
}

function getConstructorOf(obj) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ assert(Number.isInteger(child.pid));
// try killing with invalid signal
assert.throws(() => {
child.kill('foo');
}, common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL' }));
}, common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL', type: TypeError }));

assert.strictEqual(child.kill(), true);
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-spawnsync-kill-signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (process.argv[2] === 'child') {
// Verify that an error is thrown for unknown signals.
assert.throws(() => {
spawn('SIG_NOT_A_REAL_SIGNAL');
}, common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL' }));
}, common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL', type: TypeError }));

// Verify that the default kill signal is SIGTERM.
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ if (!common.isWindows) {
// Validate the killSignal option
const typeErr = /^TypeError: "killSignal" must be a string or number$/;
const unknownSignalErr =
common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL' });
common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL', type: TypeError });

pass('killSignal', undefined);
pass('killSignal', null);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-dgram-createSocket-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ invalidTypes.forEach((invalidType) => {
dgram.createSocket(invalidType);
}, common.expectsError({
code: 'ERR_SOCKET_BAD_TYPE',
type: Error,
type: TypeError,
message: errMessage
}));
});
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-process-kill-pid.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ assert.throws(function() { process.kill(-1 / 0); },
// Test that kill throws an error for invalid signal
const unknownSignal = common.expectsError({
code: 'ERR_UNKNOWN_SIGNAL',
type: Error,
type: TypeError,
message: 'Unknown signal: test'
});

Expand Down

0 comments on commit 1a452f1

Please sign in to comment.