Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
[squash] ERR_INVALID_OPT_VALUE --> ERR_INVALID_ARG_TYPE
  • Loading branch information
maclover7 committed Nov 28, 2017
commit dba4e7c83cec04b6d3013111e511b27d4886b36d
4 changes: 2 additions & 2 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,13 @@ function _convertCustomFds(options) {

function normalizeSpawnArguments(file, args, options) {
if (typeof file !== 'string' || file.length === 0)
throw new errors.TypeError('ERR_INVALID_OPT_VALUE', 'file', file);
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'file', 'string', file);

if (Array.isArray(args)) {
args = args.slice(0);
} else if (args !== undefined &&
(args === null || typeof args !== 'object')) {
throw new errors.TypeError('ERR_INVALID_OPT_VALUE', 'args', args);
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'args', 'object', args);
} else {
options = args;
args = [];
Expand Down
18 changes: 9 additions & 9 deletions test/parallel/test-child-process-spawn-typeerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const invalidcmd = 'hopefully_you_dont_have_this_on_your_machine';
const empty = fixtures.path('empty.js');

const invalidOptValueError =
common.expectsError({ code: 'ERR_INVALID_OPT_VALUE', type: TypeError }, 20);
common.expectsError({ code: 'ERR_INVALID_OPT_VALUE', type: TypeError }, 13);

const invalidArgTypeError =
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 4);
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 11);

assert.throws(function() {
const child = spawn(invalidcmd, 'this is not an array');
Expand All @@ -60,24 +60,24 @@ assert.doesNotThrow(function() {
// verify that invalid argument combinations throw
assert.throws(function() {
spawn();
}, invalidOptValueError);
}, invalidArgTypeError);

assert.throws(function() {
spawn('');
}, invalidOptValueError);
}, invalidArgTypeError);

assert.throws(function() {
const file = { toString() { return null; } };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional? What happens now if the error is thrown like in the old test?

spawn(file);
}, invalidOptValueError);
}, invalidArgTypeError);

assert.throws(function() {
spawn(cmd, null);
}, invalidOptValueError);
}, invalidArgTypeError);

assert.throws(function() {
spawn(cmd, true);
}, invalidOptValueError);
}, invalidArgTypeError);

assert.throws(function() {
spawn(cmd, [], null);
Expand Down Expand Up @@ -109,10 +109,10 @@ assert.doesNotThrow(function() { spawn(cmd, o); });
assert.doesNotThrow(function() { spawn(cmd, u, o); });
assert.doesNotThrow(function() { spawn(cmd, a, u); });

assert.throws(function() { spawn(cmd, n, o); }, invalidOptValueError);
assert.throws(function() { spawn(cmd, n, o); }, invalidArgTypeError);
assert.throws(function() { spawn(cmd, a, n); }, invalidArgTypeError);

assert.throws(function() { spawn(cmd, s); }, invalidOptValueError);
assert.throws(function() { spawn(cmd, s); }, invalidArgTypeError);
assert.throws(function() { spawn(cmd, a, s); }, invalidArgTypeError);


Expand Down