Uh oh!
There was an error while loading. Please reload this page.
fs: report source and destination files in error messages - #293
Conversation
ba7cb15 to
3fdd411Comparepiscisaureus
commented
Jan 11, 2015
Ok, that's a good start. But at a quick glance:
|
caitp
commented
Jan 12, 2015
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 |
vkurchatkin
commented
Jan 12, 2015
I think checking |
caitp
commented
Jan 12, 2015
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
68d6a12Comparecaitp
commented
Jan 12, 2015
I guess the UV request has a way to figure out request commands, but if people are happy with |
piscisaureus
commented
Jan 12, 2015
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 |
caitp
commented
Jan 12, 2015
@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 |
piscisaureus
commented
Jan 12, 2015
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 |
caitp
commented
Jan 12, 2015
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 |
piscisaureus
commented
Jan 13, 2015
Thanks |
caitp
commented
Jan 21, 2015
so what's going on here? this was as-asked-for 9 days ago =) |
Qard
commented
Jan 30, 2015
LGTM @piscisaureus Can you take another look? Both paths are there, so your concerns should be dealt with, afaict. |
piscisaureus
commented
Jan 30, 2015
@bnoordhuis@indutny WDYT, I'm unsure about the use of std::string. |
bnoordhuis
commented
Jan 30, 2015
@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. |
piscisaureus
commented
Jan 30, 2015
piscisaureus
commented
Jan 30, 2015
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#675Fixes: nodejs#207Closes: 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.