Closed
Description
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 another IOException
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 the PATH
.
What
withFile
should not annotate / change unrelated exceptions.
For example, given the file test.hs
:
import System.IO
main = withFile "test.txt" WriteMode $ \_ -> fail "test
when run with runhaskell test.hs
, produces
test.hs: test.txt: withFile: user error (test)
while it should rather exit and print:
test.hs: user error (test)
How
- Upstream issue opened by @ndmitchell https://gitlab.haskell.org/ghc/ghc/-/issues/20886
- A merge request fixing this https://gitlab.haskell.org/ghc/ghc/-/merge_requests/11866