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
fixup
  • Loading branch information
BridgeAR committed Jun 16, 2017
commit a4d753f34ad5d8e7bcd344e8491ef304eb972633
3 changes: 2 additions & 1 deletion lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const WriteWrap = process.binding('stream_wrap').WriteWrap;
const async_id_symbol = process.binding('async_wrap').async_id_symbol;
const { newUid, setInitTriggerId } = require('async_hooks');
const nextTick = require('internal/process/next_tick').nextTick;
const errors = require('internal/errors');

var cluster;
var dns;
Expand Down Expand Up @@ -873,7 +874,7 @@ function internalConnect(
var err;

if (typeof address !== 'string') {
Copy link
Copy Markdown
Contributor

@mscdex mscdex Jun 16, 2017

Choose a reason for hiding this comment

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

Can we move this to .connect() instead, under the if (pipe) check? internalConnect() is also called for non-pipe connections and so it would be an unnecessary/redundant check in those cases (since the address would be validated at time of lookup() there).

throw new TypeError('Invalid address: ' + address);
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'address', 'string');
}

if (localAddress || localPort) {
Expand Down
7 changes: 2 additions & 5 deletions test/parallel/test-net-better-error-messages-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ const assert = require('assert');
}

{
try {
assert.throws(() => {
net.createConnection({ path: {} });
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use assert.throws() here.

throw new Error('UNREACHABLE');
} catch (e) {
assert.strictEqual(e.message, 'Invalid address: [object Object]');
}
}, TypeError);
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.

Re: asserting error messages, Could you use expectsError

}