FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

url: port WHATWG URL API to internal/errors by TimothyGu · Pull Request #12574 · nodejs/node · GitHub

/ node Public

url: port WHATWG URL API to internal/errors - #12574

Closed
TimothyGu wants to merge 3 commits into
nodejs:masterfrom
TimothyGu:url-errors
Closed

url: port WHATWG URL API to internal/errors#12574
TimothyGu wants to merge 3 commits into
nodejs:masterfrom
TimothyGu:url-errors

Conversation

Copy link
Copy Markdown
Member

Refs: #11273
Refs: #11299

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)

url, errors

nodejs-github-bot added dont-land-on-v4.x errors Issues and PRs related to JavaScript errors originated in Node.js core. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Apr 21, 2017
Comment thread doc/api/errors.md Outdated

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This can also be just ERR_INVALID_ARG_TYPE with Iterable as the expected type..no strong feelings about it though.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

For this I think the more specific error is warranted.

Comment thread lib/internal/url.js Outdated

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I know the name/value thing is already in error messages...but since we are changing error messages anyway, I think [name, value] would be easier to understand at the first glance.

Comment thread doc/api/errors.md Outdated

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The "limited to WHATWG URL" part can be left out IMO, the source of errors would be visible in the stack trace anyway... This way people don't need to change this section when they add this type of error to other APIs

Comment thread doc/api/errors.md Outdated

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

[name, value] tuple would be easier to grasp..

TimothyGu Apr 24, 2017
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

"name/value tuple" is the WHATWG nomenclature, but I'm perfectly fine with "[name, value] tuple".

Comment thread doc/api/errors.md Outdated

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Note that at the moment input might not be exactly the same as the original input since it needs to go through trimming and String::NO_NULL_TERMINATION | String::REPLACE_INVALID_UTF8 first...we could've stored the original input, but that's for another PR to consider

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Right, the REPLACE_INVALID_UTF8 is pretty edge-case, but trimming can indeed be something the user does not expect. Agreed on addressing this in a separate PR though.

Comment thread doc/api/errors.md Outdated

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

In that case, why not just use 'ERR_INVALID_ARG_TYPE'?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

'ERR_INVALID_ARG_TYPE' has the following templated message:

The "FOO" argument must be of type BAR.

In this case, it is not the question of what type the argument is, but whether it is defined at all.

Comment thread lib/internal/errors.js Outdated

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Maybe surround this with quotes or backticks? The original error message uses backticks.

TimothyGu Apr 25, 2017
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It's quite rare to have an error message with backticks in it (most error messages use double quotes). Here are a few alternatives:

  1. Value of "this" must be of type %s
  2. Method called on incompatible receiver of type %s (V8-inspired)
  3. Method called on incompatible %s (SpiderMonkey-inspired)

Choice 1 SGTM.

Comment thread lib/internal/errors.js Outdated

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think undefined should be in the message here..otherwise if the user makes a mistake and passes an undefined, there is no way to know if it is an undefined or just an empty string.

Comment thread lib/internal/url.js Outdated

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It's a bit weird to put the verbs in separate places...maybe the must part can be left out in the error message format and written here?

Comment thread test/common.js Outdated

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Or maybe err instanceof code.constructor ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't know about this one, I'm generally not a huge fan of instanceof checks due to unreliability across different V8 contexts, and it is quite possible that WPT's testharness.js uses the error name string check instead of instanceof.

jasnell left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'd like to see @joyeecheung's comments addressed.

Copy link
Copy Markdown
Member Author

Addressed most of @joyeecheung's comments, except those that are still visible above.

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member Author

Landed in d457a98.

TimothyGu closed this Apr 25, 2017
TimothyGu deleted the url-errors branch April 25, 2017 23:34
TimothyGu added a commit that referenced this pull request Apr 25, 2017
Also slightly revises grammar.

PR-URL: #12574
Refs: #11273
Refs: #11299
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
jasnell mentioned this pull request May 11, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

errors Issues and PRs related to JavaScript errors originated in Node.js core. whatwg-url Issues and PRs related to the WHATWG URL implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL