| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@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 |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
FYI you could just use %s place holders, but IMHO this way is more readable.
Sorry, something went wrong.
There was a problem hiding this comment.
But: consistency 😉
Sorry, something went wrong.
There was a problem hiding this comment.
There is none anyway...
I'll open a PR to change them all.
Sorry, something went wrong.
|
Whoever lands this: I think the subsystem should be http_client with an underscore. |
Sorry, something went wrong.
|
@refack I've added some tests for the new errors in test/parallel/test-internal-errors.js😀 |
Sorry, something went wrong.
|
semver-major so pinging @nodejs/ctc for some reviews |
Sorry, something went wrong.
There was a problem hiding this comment.
💯
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
|
@starkwang Sorry to be a bummer, but can you rebase this against master? There are some merge conflicts here… |
Sorry, something went wrong.
There was a problem hiding this comment.
It seems that I missing some titles for errors.md in #14212 . So I added the missing titles in this PR
Sorry, something went wrong.
There was a problem hiding this comment.
It seems that I missing some titles for errors.md in #14212 . So I added the missing titles in this PR
Sorry, something went wrong.
|
@addaleax I've just rebased the branch : ) |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
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! 😃
Sorry, something went wrong.
There was a problem hiding this comment.
Unless I am missing something, it does not appear to be necessary to use a regular expression here, a string literal should work just fine. By the way, if you want to match an exact string using regular expressions, use start (^) and end markers ($). Otherwise, the match will succeed even if there is content before or after the expression:
const expr = /The "method" argument must be of type string/;
const str = 'The "method" argument must be of type string. Also, this sentence should not be here';
expr.test(str) === true
Sorry, something went wrong.
There was a problem hiding this comment.
Same here, why is this a regular expression?
Sorry, something went wrong.
There was a problem hiding this comment.
Same here.
Sorry, something went wrong.
There was a problem hiding this comment.
Grammar: have been sent. Also, http probably refers to the protocol instead of the module name, so I would prefer HTTP over http.
Sorry, something went wrong.
There was a problem hiding this comment.
Used when new HTTP headers are added to a response, after the headers part has already been sent.
Sorry, something went wrong.
There was a problem hiding this comment.
http probably refers to the protocol instead of the module name, so I would prefer HTTP over http.
Sorry, something went wrong.
There was a problem hiding this comment.
Grammar: that be passed. I would just say "... failed to parse the host or hostname option".
Sorry, something went wrong.
There was a problem hiding this comment.
Used when `hostname` can not be parsed from a provided URL.
Sorry, something went wrong.
There was a problem hiding this comment.
Grammar: when receive. Should probably be when receiving.
Sorry, something went wrong.
There was a problem hiding this comment.
Used when a string that contains unescaped characters was received.
Sorry, something went wrong.
There was a problem hiding this comment.
I don't have a strong opinion on this, I would prefer a more meaningful name for this error code. From the error code, the actual reason of the error is unclear, and the message implies that having the headers sent already is the only reason sending headers can fail, ever, and I am not too sure about that. Maybe something like ERR_HEADERS_SENT? Doesn't sound perfect either... cc @refack
Sorry, something went wrong.
There was a problem hiding this comment.
ERR_HTTP_HEADERS_SENT
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
This PR has http, internal errors, and is semver major. Seems like @jasnell should be all over it. Ping! :-D |
Sorry, something went wrong.
|
Pushed commit to address comments |
Sorry, something went wrong.
There was a problem hiding this comment.
💯
Sorry, something went wrong.
Sorry, something went wrong.
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
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
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>
| Back | FazBrowse Home | New Git URL |
Ref: #11273
Checklist
Affected core subsystem(s)
errors, http_client