-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
fs: migrate more errors to internal/errors #17667
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
Conversation
2b87e7d to
0e284e1
Compare
doc/api/errors.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this principle has been decided previously, but maybe not?:
Is it desirable to have such specific codes? Why not just ERR_INVALID_ARG_VALUE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's been debated and I'm good with it either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be in favor of erring on the side of more general and you can always move to a more specific code later if it turns out it's really needed. But yeah, if there's fierce opinions on both sides, then ¯\(ツ)/¯
lib/fs.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ERR_OUT_OF_RANGE is reduced into ERR_VALUE_OUT_OF_RANGE in #17648. So here would be better to use ERR_VALUE_OUT_OF_RANGE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasnell ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, was holding off a bit to see if/when #17648 was going to land.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh.. right, and the latest updates remove the out of range errors anyway so this is no longer relevant ;-)
lib/internal/errors.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would justify this new error a bit more if the error message includes a list of valid symlink types
|
ping @nodejs/tsc |
0e284e1 to
c57266d
Compare
|
Chose to go with @joyeecheung's suggestion of a more specific error message. PTAL |
0c2cf69 to
a93e157
Compare
|
Thank you @joyeecheung :-) ... @nodejs/tsc ... need one more TSC sign off please. |
|
Looks like there was something wrong with linux one, new linux one CI: https://ci.nodejs.org/job/node-test-commit-linuxone/11371/ |
lib/fs.js
Outdated
| throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'path', | ||
| ['string', 'Buffer', 'URL']); | ||
| } | ||
| if (!Number.isInteger(uid)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also check for uid >= 0? Same question for the other checks in this commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do believe that uid and gid both can be negative in some edge cases.
lib/fs.js
Outdated
|
|
||
| var req = new FSReqWrap(); | ||
| if (!Number.isInteger(fd)) | ||
| throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'fd', 'number'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/number/integer/
lib/fs.js
Outdated
| // fs.writeSync(fd, string[, position[, encoding]]); | ||
| fs.writeSync = function(fd, buffer, offset, length, position) { | ||
| if (!Number.isInteger(fd)) | ||
| throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'fd', 'number'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/number/integer/
lib/fs.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
doc/api/errors.md
Outdated
| [`ERR_INVALID_ARG_TYPE`]: #ERR_INVALID_ARG_TYPE | ||
| [`EventEmitter`]: events.html#events_class_eventemitter | ||
| [`fs.symlink()`]: fs.html#fs_symlink | ||
| [`fs.symlinkSync()`]: fs.html#fs_symlinksymc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: symlinksync
|
General question about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the nits already noted addresses
Replacing Another issue with |
|
Updated to address @bnoordhuis' feedback. @mcollina and @joyeecheung ... please take another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the nit above adressed.
lib/fs.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasnell ^
src/node_file.cc
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsInt32 (both lines)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FChown is not changed in this PR and also gets Uint32Value(). Are you sure negative uid and gid are possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... they are definitely theoretically possible but you're right. I'll keep these as uint32s
469c61a to
4e75058
Compare
4e75058 to
a2d9bd7
Compare
PR-URL: #17667 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
|
Landed in 6100e12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Belated LGTM
|
@jasnell it looks like the new assertions in |
|
@apapirovski The CITGM issues are caused by |
PR-URL: #17852 Refs: #17667 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
PR-URL: #17852 Refs: #17667 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Next batch of fs type checking migrations to use internal/errors
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
fs