-
Notifications
You must be signed in to change notification settings - Fork 58
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
Misleading error message for spew in non-existent dir #290
Comments
Only thing is that that is in fact the name of the file Path::Tiny actually did try to open. If it had succeeded in creating that file and writing the contents to it then it would afterwards have renamed that file to But now there is a problem with the error message: what you think is misleading is actually what’s really going on – and if the error message named the file you passed, rather than the one Path::Tiny actually tried to open, then that would in fact be misleading. But of course you’re right that the error is confusing if you’re not aware of what’s going on. @xdg: maybe the answer here is to mention both in the error message? (Something along the lines of |
How about we check if the directory exists first, and then the Error can be "Error: target directory 'dir_does_not_exist' does not exist" ? That might be racey, but for 99.9999% of cases we can avoid the confusing error. |
I do remember reading about the renaming (which of course is good practice) in the docs. Thanks for reminding me; now at least I understand what’s going on. The fact is, even though I did read it in the past, I didn’t think of it when I encountered this issue just then. Perhaps I would have thought of it if the temporary name hinted at the fact it’s temporary. Doesn’t have to be something in |
It’s an option, but I’m -1 on reporting that instead of the actual error. If I had to debug an error I’d want to know the specific operation that failed and the actual error it got, not just the error-handling code’s guess at the reason for the error. And at that point the error starts to get rather wordy. It’s also extra code to handle just one particular case. (It might not even be the immediate parent directory that’s missing, but one further up the path. Do you try to handle that? What about permissions issues? Etc.) I’m curious how @xdg feels about it but personally I would be disinclined.
Not sure. Remember that path names are limited in length; if you look at the (As for @xdg: idle thought after typing this all up: maybe the fact that the code goes to some lengths to place the file in the target directory and only change the final path component means that the error message could omit the directories for the original path, so more like |
Being truthful sounds good to me! Another idle thought: |
Or maybe “temporary name”? Anyway, let’s see what @xdg thinks. |
Hi. Catching up here. Would something like this be what we want?
|
Yes, nice. LGTM |
0.145-TRIAL looks good to me so far. Thanks! |
Thanks for the feedback! I have a calendar reminder to ship stable next week after I check CPAN Testers. |
When I tell Path::Tiny 0.144 (on Perl v5.39.9) to
spew
orspew_raw
a file into a directory that hasn't been created yet, the error message misleadingly states the wrong file name:Expected:
Actual:
The text was updated successfully, but these errors were encountered: