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

path: Fix the error message of path.format #14030

Closed
wants to merge 1 commit into from

Conversation

starkwang
Copy link
Contributor

@starkwang starkwang commented Jul 1, 2017

The last argument of invalidArgType(name, expected, actual) in internal/errors.js is an actual value, NOT the type of actual value.

This causes:

path.format(123)
//=> TypeError [ERR_INVALID_ARG_TYPE]: The "pathObject" argument must be of type Object. Received type string

The last word "string" should be "number".

A parallel test is added for this method.

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

path

@nodejs-github-bot nodejs-github-bot added the path Issues and PRs related to the path subsystem. label Jul 1, 2017
@@ -960,7 +960,7 @@ const win32 = {
format: function format(pathObject) {
if (pathObject === null || typeof pathObject !== 'object') {
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'pathObject', 'Object',
typeof pathObject);
pathObject);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we align this with the argument above it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will exceed the maximum line length of 80

@@ -1503,7 +1503,7 @@ const posix = {
format: function format(pathObject) {
if (pathObject === null || typeof pathObject !== 'object') {
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'pathObject', 'Object',
typeof pathObject);
pathObject);
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@cjihrig
Copy link
Contributor

cjihrig commented Jul 1, 2017

I think these fixes are already in #14011.

@starkwang starkwang closed this Jul 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
path Issues and PRs related to the path subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants