Skip to content

Commit 1a452f1

Browse files
BridgeARtniessen
authored andcommitted
dgram,process,util: refactor Error to TypeError
PR-URL: #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]>
1 parent 1698c8e commit 1a452f1

8 files changed

+8
-8
lines changed

lib/dgram.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function newHandle(type) {
7979
return handle;
8080
}
8181

82-
throw new errors.Error('ERR_SOCKET_BAD_TYPE');
82+
throw new errors.TypeError('ERR_SOCKET_BAD_TYPE');
8383
}
8484

8585

lib/internal/process.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ function setupKillAndExit() {
181181
if (lazyConstants()[sig]) {
182182
err = process._kill(pid, lazyConstants()[sig]);
183183
} else {
184-
throw new errors.Error('ERR_UNKNOWN_SIGNAL', `${sig}`);
184+
throw new errors.TypeError('ERR_UNKNOWN_SIGNAL', sig);
185185
}
186186
}
187187

lib/internal/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function convertToValidSignal(signal) {
180180
if (signalName) return signalName;
181181
}
182182

183-
throw new errors.Error('ERR_UNKNOWN_SIGNAL', signal);
183+
throw new errors.TypeError('ERR_UNKNOWN_SIGNAL', signal);
184184
}
185185

186186
function getConstructorOf(obj) {

test/parallel/test-child-process-constructor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ assert(Number.isInteger(child.pid));
6868
// try killing with invalid signal
6969
assert.throws(() => {
7070
child.kill('foo');
71-
}, common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL' }));
71+
}, common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL', type: TypeError }));
7272

7373
assert.strictEqual(child.kill(), true);

test/parallel/test-child-process-spawnsync-kill-signal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if (process.argv[2] === 'child') {
3131
// Verify that an error is thrown for unknown signals.
3232
assert.throws(() => {
3333
spawn('SIG_NOT_A_REAL_SIGNAL');
34-
}, common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL' }));
34+
}, common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL', type: TypeError }));
3535

3636
// Verify that the default kill signal is SIGTERM.
3737
{

test/parallel/test-child-process-spawnsync-validation-errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ if (!common.isWindows) {
186186
// Validate the killSignal option
187187
const typeErr = /^TypeError: "killSignal" must be a string or number$/;
188188
const unknownSignalErr =
189-
common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL' });
189+
common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL', type: TypeError });
190190

191191
pass('killSignal', undefined);
192192
pass('killSignal', null);

test/parallel/test-dgram-createSocket-type.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ invalidTypes.forEach((invalidType) => {
2727
dgram.createSocket(invalidType);
2828
}, common.expectsError({
2929
code: 'ERR_SOCKET_BAD_TYPE',
30-
type: Error,
30+
type: TypeError,
3131
message: errMessage
3232
}));
3333
});

test/parallel/test-process-kill-pid.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ assert.throws(function() { process.kill(-1 / 0); },
6060
// Test that kill throws an error for invalid signal
6161
const unknownSignal = common.expectsError({
6262
code: 'ERR_UNKNOWN_SIGNAL',
63-
type: Error,
63+
type: TypeError,
6464
message: 'Unknown signal: test'
6565
});
6666

0 commit comments

Comments
 (0)