Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors, path: migrate to use internal/errors.js #11319

Closed
wants to merge 1 commit into from

Conversation

@seppevs
Copy link
Contributor

@seppevs seppevs commented Feb 12, 2017

Migrate path.js to use internal/errors.js.

Refs: #11273

cc @jasnell

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

errors,path

lib/path.js Outdated

function assertPath(path) {
if (typeof path !== 'string') {
throw new TypeError('Path must be a string. Received ' + inspect(path));
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'path', 'String');

This comment has been minimized.

@thefourtheye

thefourtheye Feb 12, 2017
Contributor

Why typeof path is not passed?

This comment has been minimized.

@seppevs

seppevs Feb 13, 2017
Author Contributor

The typeof path was not passed before the change. The inspect(path) returned the value, this is not something the ERR_INVALID_ARG_TYPE supports.

@thefourtheye thefourtheye mentioned this pull request Feb 12, 2017
4 of 4 tasks complete
@thefourtheye
Copy link
Contributor

@thefourtheye thefourtheye commented Feb 12, 2017

Related: #11308 also has an implementation for invalidArgType.

@seppevs
Copy link
Contributor Author

@seppevs seppevs commented Feb 13, 2017

@thefourtheye : yes, it's the same implementation. Just like in #11300

@jasnell jasnell mentioned this pull request Feb 14, 2017
79 of 80 tasks complete
@jasnell jasnell added the blocked label Apr 5, 2017
@refack refack force-pushed the nodejs:master branch to fbe946b Apr 14, 2017
@seppevs seppevs force-pushed the seppevs:path_use_internal_errors branch May 1, 2017
@seppevs
Copy link
Contributor Author

@seppevs seppevs commented May 1, 2017

I've just rebased this.

lib/path.js Outdated
@@ -816,7 +816,7 @@ const win32 = {

basename: function basename(path, ext) {
if (ext !== undefined && typeof ext !== 'string')
throw new TypeError('"ext" argument must be a string');
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'ext', 'String');

This comment has been minimized.

@jasnell

jasnell May 1, 2017
Member

hmm... I'm thinking string (lowercase) would be better on these.

This comment has been minimized.

@seppevs

seppevs May 3, 2017
Author Contributor

Fixed

@seppevs seppevs force-pushed the seppevs:path_use_internal_errors branch to a567257 May 3, 2017
Copy link
Member

@refack refack left a comment

@@ -16,7 +16,7 @@ assert.throws(function() {

assert.throws(function() {
fs.watchFile(new Object(), common.noop);
}, /Path must be a string/);
}, common.expectsError({code: 'ERR_INVALID_ARG_TYPE', type: TypeError}));

This comment has been minimized.

@refack

refack May 3, 2017
Member

Could you add an assertion on the message as well?
(Changing the message is semver-major so let's enforce it)

This comment has been minimized.

@fhinkel

fhinkel May 23, 2017
Member

This is a semver-major change, so it's totally fine to change the message.

This comment has been minimized.

@refack

refack May 23, 2017
Member

Yes, but let's keep it from regressing.

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

This comment has been minimized.

@refack

refack May 3, 2017
Member

ditto.
(You can turn this into a Factory that takes the messages)

@@ -372,7 +372,7 @@ function fail(fn) {

assert.throws(() => {
fn.apply(null, args);
}, TypeError);
}, common.expectsError({code: 'ERR_INVALID_ARG_TYPE', type: TypeError}));

This comment has been minimized.

@refack

refack May 3, 2017
Member

Tritto

@fhinkel
Copy link
Member

@fhinkel fhinkel commented May 23, 2017

@seppevs Thanks so much for putting this together. Sorry that it is dragging out for so long due to being a semver-major change.

@jasnell Could you take another look? I think your comment has been addressed.

CI: https://ci.nodejs.org/job/node-test-pull-request/8255/

@refack
Copy link
Member

@refack refack commented May 23, 2017

CI: https://ci.nodejs.org/job/node-test-pull-request/8255/

CI failures are infrastructure related.

Copy link
Member

@mhdawson mhdawson left a comment

LGTM

{method: 'format', input: [null], message: expectedMessage},
{method: 'format', input: [''], message: expectedMessage},
{method: 'format', input: [true], message: expectedMessage},
{method: 'format', input: [1], message: expectedMessage},

This comment has been minimized.

@mhdawson

mhdawson Jun 6, 2017
Member

We'll need to agree on whether the tests should check the contents of the message or not, but since have landed tests both with and without, I'm fine with landing as is.

@mhdawson
Copy link
Member

@mhdawson mhdawson commented Jun 6, 2017

@refack I can't quite tell from the comments/discussion if your suggestions have been addressed and you are ok with this landing. It looks like the CI is good and it may be ready to go but I'd like to be sure. Since the CI is also 2 weeks old we probably want to run a new one.

@refack
refack approved these changes Jun 6, 2017
@refack
Copy link
Member

@refack refack commented Jun 6, 2017

We'll need to agree on whether the tests should check the contents of the message or not, but since have landed tests both with and without, I'm fine with landing as is.

@mhdawson Like you said, not worth blocking for full message validation.

@mhdawson
Copy link
Member

@mhdawson mhdawson commented Jun 6, 2017

@refack thanks for the quick response. I'll open an issue where we can discuss what we think is the right way to go on the messages and then we can do a second pass to fix up based on what we decide.

New CI run: https://ci.nodejs.org/job/node-test-pull-request/8517/

@mhdawson mhdawson removed the blocked label Jun 6, 2017
@mhdawson
Copy link
Member

@mhdawson mhdawson commented Jun 6, 2017

OSX CI failure looks unrelated. Opened this issue to track: #13507

@mhdawson
Copy link
Member

@mhdawson mhdawson commented Jun 6, 2017

CI good so landing.

@mhdawson
Copy link
Member

@mhdawson mhdawson commented Jun 6, 2017

Landed as dcfbbac

@mhdawson mhdawson closed this Jun 6, 2017
mhdawson added a commit that referenced this pull request Jun 6, 2017
PR-URL: #11319
Ref: #11273
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@refack refack added this to Done in Error Codes Aug 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Error Codes
  
Done
Linked issues

Successfully merging this pull request may close these issues.

None yet

8 participants
You can’t perform that action at this time.