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

http_client, errors: migrate to use internal/errors #14423

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
8 participants
@starkwang
Contributor

starkwang commented Jul 22, 2017

Ref: #11273

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, http_client

@refack

refack approved these changes Jul 22, 2017

@refack

This comment has been minimized.

Show comment
Hide comment
@refack

refack Jul 22, 2017

Member

@starkwang thank you so much for helping with this!

We recently updated the recommended way to test internal Errors — https://github.com/nodejs/node/pull/14207/files
tl;dr need to test the message only if it's variable, and once is enough (in test/parallel/test-internal-errors.js).
IMHO the PR is good as is, but it would be great if you followed up and made it even better.

/cc @jasnell @fhinkel @Trott @mhdawson

Member

refack commented Jul 22, 2017

@starkwang thank you so much for helping with this!

We recently updated the recommended way to test internal Errors — https://github.com/nodejs/node/pull/14207/files
tl;dr need to test the message only if it's variable, and once is enough (in test/parallel/test-internal-errors.js).
IMHO the PR is good as is, but it would be great if you followed up and made it even better.

/cc @jasnell @fhinkel @Trott @mhdawson

@refack

This comment has been minimized.

Show comment
Hide comment

@jasnell jasnell referenced this pull request Jul 22, 2017

Closed

Tracking Issue: Migrate errors to internal/errors.js #11273

78 of 80 tasks complete
E('ERR_INVALID_FD', '"fd" must be a positive integer: %s');
E('ERR_INVALID_FILE_URL_HOST',
'File URL host must be "localhost" or empty on %s');
E('ERR_INVALID_FILE_URL_PATH', 'File URL path %s');
E('ERR_INVALID_HANDLE_TYPE', 'This handle type cannot be sent');
E('ERR_INVALID_HTTP_TOKEN', (name) => `${name} must be a valid HTTP token`);

This comment has been minimized.

@refack

refack Jul 22, 2017

Member

FYI you could just use %s place holders, but IMHO this way is more readable.

@refack

refack Jul 22, 2017

Member

FYI you could just use %s place holders, but IMHO this way is more readable.

This comment has been minimized.

@tniessen

tniessen Jul 22, 2017

Member

But: consistency 😉

@tniessen

tniessen Jul 22, 2017

Member

But: consistency 😉

This comment has been minimized.

@refack

refack Jul 22, 2017

Member

There is none anyway...
I'll open a PR to change them all.

@refack

refack Jul 22, 2017

Member

There is none anyway...
I'll open a PR to change them all.

@tniessen

This comment has been minimized.

Show comment
Hide comment
@tniessen

tniessen Jul 22, 2017

Member

Whoever lands this: I think the subsystem should be http_client with an underscore.

Member

tniessen commented Jul 22, 2017

Whoever lands this: I think the subsystem should be http_client with an underscore.

@starkwang

This comment has been minimized.

Show comment
Hide comment
@starkwang

starkwang Jul 22, 2017

Contributor

@refack I've added some tests for the new errors in test/parallel/test-internal-errors.js😀

Contributor

starkwang commented Jul 22, 2017

@refack I've added some tests for the new errors in test/parallel/test-internal-errors.js😀

@Trott Trott added the semver-major label Jul 22, 2017

@Trott

This comment has been minimized.

Show comment
Hide comment
@Trott

Trott Jul 22, 2017

Member

semver-major so pinging @nodejs/ctc for some reviews

Member

Trott commented Jul 22, 2017

semver-major so pinging @nodejs/ctc for some reviews

@refack

refack approved these changes Jul 22, 2017

💯

@mcollina

LGTM

@addaleax

This comment has been minimized.

Show comment
Hide comment
@addaleax

addaleax Jul 26, 2017

Member

@starkwang Sorry to be a bummer, but can you rebase this against master? There are some merge conflicts here…

Member

addaleax commented Jul 26, 2017

@starkwang Sorry to be a bummer, but can you rebase this against master? There are some merge conflicts here…

@@ -597,6 +597,7 @@ Used when `Console` is instantiated without `stdout` stream or when `stdout` or
Used when the native call from `process.cpuUsage` cannot be processed properly.
<a id="ERR_DNS_SET_SERVERS_FAILED"></a>
### ERR_DNS_SET_SERVERS_FAILED

This comment has been minimized.

@starkwang

starkwang Jul 27, 2017

Contributor

It seems that I missing some titles for errors.md in #14212 . So I added the missing titles in this PR

@starkwang

starkwang Jul 27, 2017

Contributor

It seems that I missing some titles for errors.md in #14212 . So I added the missing titles in this PR

Show outdated Hide outdated doc/api/errors.md Outdated
@starkwang

This comment has been minimized.

Show comment
Hide comment
@starkwang

starkwang Jul 27, 2017

Contributor

@addaleax I've just rebased the branch : )

Contributor

starkwang commented Jul 27, 2017

@addaleax I've just rebased the branch : )

@addaleax

This comment has been minimized.

Show comment
Hide comment
Member

addaleax commented Jul 27, 2017

@tniessen

From using-internal-errors.md:

If the error message is not a constant string then tests to validate the formatting of the message based on the parameters used when creating the error should be added to test/parallel/test-internal-errors.js. These tests should validate all of the different ways parameters can be used to generate the final message string.

And this section:

In addition, there should also be tests which validate the use of the error based on where it is used in the codebase. For these tests, except in special cases, they should only validate that the expected code is received and NOT validate the message.

I don't exactly care about this, just remember that this PR does not strictly comply with these guidelines.

Thanks for your efforts @starkwang! 😃

Show outdated Hide outdated test/parallel/test-http-client-check-http-token.js Outdated
Show outdated Hide outdated test/parallel/test-http-hostname-typechecking.js Outdated
Show outdated Hide outdated test/parallel/test-http-hostname-typechecking.js Outdated

@starkwang starkwang changed the title from http client, errors: migrate to use internal/errors to http_client, errors: migrate to use internal/errors Jul 28, 2017

Show outdated Hide outdated doc/api/errors.md Outdated
Show outdated Hide outdated doc/api/errors.md Outdated
Show outdated Hide outdated doc/api/errors.md Outdated
Show outdated Hide outdated doc/api/errors.md Outdated
Show outdated Hide outdated lib/_http_client.js Outdated
@refack

This comment has been minimized.

Show comment
Hide comment
@refack

refack Jul 29, 2017

Member

IMHO the documentation improvements should be non blockers, since simply migrating the Errors is of higher priority. But it's definatly nice to have while we wait for another @nodejs/ctc approval.

Member

refack commented Jul 29, 2017

IMHO the documentation improvements should be non blockers, since simply migrating the Errors is of higher priority. But it's definatly nice to have while we wait for another @nodejs/ctc approval.

@Trott

This comment has been minimized.

Show comment
Hide comment
@Trott

Trott Jul 29, 2017

Member

This PR has http, internal errors, and is semver major. Seems like @jasnell should be all over it. Ping! :-D

Member

Trott commented Jul 29, 2017

This PR has http, internal errors, and is semver major. Seems like @jasnell should be all over it. Ping! :-D

@starkwang

This comment has been minimized.

Show comment
Hide comment
@starkwang

starkwang Jul 30, 2017

Contributor

Pushed commit to address comments

Contributor

starkwang commented Jul 30, 2017

Pushed commit to address comments

@refack

refack approved these changes Jul 30, 2017

💯

@refack

This comment has been minimized.

Show comment
Hide comment
@tniessen

This comment has been minimized.

Show comment
Hide comment
@tniessen

tniessen Aug 1, 2017

Member

Landed in bdfbce9.

Member

tniessen commented Aug 1, 2017

Landed in bdfbce9.

@tniessen tniessen closed this Aug 1, 2017

tniessen added a commit that referenced this pull request Aug 1, 2017

http_client, errors: migrate to internal/errors
PR-URL: #14423
Refs: #11273
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>

@refack refack added this to Done in Error Codes Aug 20, 2017

MylesBorins added a commit to MylesBorins/node that referenced this pull request Sep 13, 2017

errors: backport ERR_INVALID_PROTOCOL to v8.x
This error code originally landed in a semver-major commit and is used
by the ESM implementation. This backport includes the error message
and the documentation for the error.

I did attempt to write a test for this, but it did not seem possible
to catch an exception during import, I was also unable to execute
`node --experimental-modules` properly inside of a child_process.

I'll dig more into getting a test together, but we should backport
this fix in the mean time.

Refs: nodejs#14423
Fixes: nodejs#15374

MylesBorins added a commit that referenced this pull request Sep 14, 2017

errors: backport ERR_INVALID_PROTOCOL to v8.x
This error code originally landed in a semver-major commit and is used
by the ESM implementation. This backport includes the error message
and the documentation for the error.

I did attempt to write a test for this, but it did not seem possible
to catch an exception during import, I was also unable to execute
`node --experimental-modules` properly inside of a child_process.

I'll dig more into getting a test together, but we should backport
this fix in the mean time.

Refs: #14423
Fixes: #15374

MylesBorins added a commit that referenced this pull request Sep 14, 2017

errors: backport ERR_INVALID_PROTOCOL to v8.x
This error code originally landed in a semver-major commit and is used
by the ESM implementation. This backport includes the error message
and the documentation for the error.

I did attempt to write a test for this, but it did not seem possible
to catch an exception during import, I was also unable to execute
`node --experimental-modules` properly inside of a child_process.

I'll dig more into getting a test together, but we should backport
this fix in the mean time.

Refs: #14423
Fixes: #15374

PR-URL: #15388
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

@Trott Trott referenced this pull request Oct 4, 2017

Closed

test: fix assert.throws in test-http-invalid-urls #15678

2 of 2 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment