-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
fs: report source and destination files in error messages #293
Conversation
ba7cb15
to
3fdd411
Compare
Ok, that's a good start. But at a quick glance:
|
How are you coming to the conclusion that it doesn't work for sync calls?
Unless you're referring to synchronous failures in If there is dead code left behind (I assume you mean the branch just underneath which tests for conditions where errors should be reported re: the destination path), a smart compiler will remove them --- however, I don't expect that this is dead code, just yet, and that branch should probably take precedence over the new one.
There are lots of approaches. Adding a flag to the macros and ReqWrap objects indicating the call type (big change), using a hash (not worth it for the small number of cases that matter), just testing against an enumerated number with something like |
I think checking |
Okay, well doing that will definitely create some dead code, and I'm of the opinion that the code which is removed is generally more useful (because, a caller is able to deduce the specific file which is problematic more easily). I'll change it to do that I guess |
3fdd411
to
68d6a12
Compare
I guess the UV request has a way to figure out request commands, but if people are happy with |
You're right, I was wrong. It does work for sync calls.
Indeed. That branch makes the error include the "dest" path instead of the "source" path in certain cases. Not in a way that makes any sense. That's the part I'd like you to improve.
There's a |
@piscisaureus yeah --- I changed it to the simpler approach, which removes the dead code. Personal opinion, the now-dead code was useful. It makes sense to report the file which was the cause of the signal. The extra information is good too, but maybe it would make sense to put it in parentheses after the single-file error message, so you get both more helpful information and less compat-risk. If that sounds good, I could do a followup or just change it in the PR when I have some time |
I disagree. The now-dead code was misleading; if you get EPERM in a rename operation that can mean many things, some of them related to the old filename (not allowed to rename), others may be related to the new filename (the new name already exists and you're not allowed to overwrite the file). For symlinks, it almost never makes any sense to put the symlink contents (../foo/bar) in the error message since the contents are not validated, thus can't generate an error. The only exception is windows when you're creating a junction. That's why I suggested to put both paths in the filename for |
There are definitely cases where you do want the single-file error though, depending on the command and the signal, and it's nice to be specific about this. Whatever you like though |
Thanks |
so what's going on here? this was as-asked-for 9 days ago =) |
LGTM @piscisaureus Can you take another look? Both paths are there, so your concerns should be dealt with, afaict. |
@bnoordhuis @indutny WDYT, I'm unsure about the use of std::string. |
@piscisaureus I don't mind. I've discussed with @indutny before that I'd be alright with moving more of our homegrown code over to STL. Frivolous string appending is something I would avoid in general because of the potential O(n) number of allocations but here it's probably alright. A simple snprintf() works too, of course. |
It's nothing personal, but I'm not going to land this. A lot more needed to be cleaned up (notice how |
* Include a description for the error message * For rename, link, and symlink, include both the source and destination path in the error message. * Expose the destination path as the `dest` property on the error object. * Fix a bug where `ThrowUVException()` would incorrectly delegate to `Environment::TrowErrnoException()`. API impact: * Adds an extra overload for node::UVException() which takes 6 arguments. PR: nodejs#675 Fixes: nodejs#207 Closes: nodejs#293 Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
In some cases, only reporting the source or destination file makes sense.
There is a potential compat risk if modules are post-processing the error message in some way.