-
Notifications
You must be signed in to change notification settings - Fork 14
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
Fix base/System.IO.withFile to only annotate own exceptions #237
Comments
Since no API is changed, I guess this doesn't need an impact assessment? Although I expect that some tests examining error messages could break. I'm not sure we require running tests on clc-stackage (and afair that's problematic anyway). |
I backported the change to 9.6, so if anyone wants to try to run some selective tests:
|
Thanks @ch1bo! Could you please copy the proposal here and update the top post? It's easier to discuss things when it's in the same place. |
@Bodigrim Done and also updated the upstream MR based on your comments. |
What is the behavior of I think it will now show filedescriptor information in Is that less or more confusing? |
It seems the base version of |
This looks simple enough and impactful enough to proceed with a vote sooner than usual. Dear CLC members, let's vote on the proposal to amend @hasufell @mixphix @angerman @parsonsmatt @tomjaguarpaw @velveteer +1 from me. This dovetails nicely into our recent efforts to improve UX of IO exceptions. |
+1 |
1 similar comment
+1 |
+1 This seems like an improvement because the old message was rather confusing, that is, it's more confusing to see
than
because the connection to the
I'd would be in support of that, if anyone wanted to make a follow-up proposal. |
@tomjaguarpaw IO actions that use the file-handle inside the withFile block and fail should already print the proper filepath the handle is related to. I'm not sure it's relevant how the handle was obtained. For IO actions unrelated to the file handle, I don't think we need any more information. |
Possibly. My suggestion would be to "piggyback" on the |
I'm also confused why this change isn't also made for |
That seems to be an oversight. Please comment on the MR. |
Not only confusing, but also misleading. main = withFile "test.txt" WriteMode $ \h -> do
cnt <- readFile "foo.txt"
hPut h cnt There could have been an exception in |
I'm not sure of potential consequences of accumulating error messages in user land (could they get too long? could their concatenation trigger more exceptions?). Backtraces for exceptions look like a more robust solution. |
Fair enough. I don't feel strongly. Yes, my suggestion is a hacky replication of some of the work of backtraces. Maybe best to ignore it. |
I'd feel a lot better about this if we had the backtraces already. Exception provenance information is already hard enough to come by (unless you're using So, weak -1 since we're in a pre-backtraces world. In a backtraces world, I'd like to additionally see a |
@parsonsmatt what information does |
@tomjaguarpaw @hasufell I have also fixed |
Thanks @ch1bo. Since the MR was updated, strictly speaking, we have to vote anew, but I do not really expect people to revoke their votes since you just fixed an inadverent omission of |
+1 |
Still +1 |
Thanks all, that's enough votes to approve. |
Why
withFile
annotating any exception raised within the wrapped action is misleading when debugging. It makes users think that something is wrong with the file opened, although anotherIOException
was raised. This is particularly confusing if "not found" errors of other files are raised, e.g. trying to start a process which is not found on thePATH
.What
withFile
should not annotate / change unrelated exceptions.For example, given the file
test.hs
:when run with
runhaskell test.hs
, produceswhile it should rather exit and print:
How
The text was updated successfully, but these errors were encountered: