-
Notifications
You must be signed in to change notification settings - Fork 5
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
Make sure to set ioe_filename in IOException #18
Conversation
Fixes #17 Also improves the property tests to examine more of the IOException.
h <- openFile fp iomode | ||
openBinaryFile osfp iomode = augmentError "openBinaryFile" osfp $ openBinaryFile' osfp iomode | ||
|
||
openBinaryFile' :: OsPath -> IOMode -> IO Handle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internal variant so that withFile
doesn't accumulate two augmentError
calls
hClose | ||
action | ||
(try . action)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same as haskell/core-libraries-committee#237
|
||
addFilePathToIOError :: String -> OsPath -> IOException -> IOException | ||
addFilePathToIOError fun fp ioe = unsafePerformIO $ do | ||
fp' <- either (const (fmap OSP.toChar . OSP.unpack $ fp)) id <$> try @SomeException (OSP.decodeFS fp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches the logic in unix: https://github.com/haskell/unix/blob/7db23ecad7593210ce38c48a462be6c50d080e00/System/Posix/PosixPath/FilePath.hsc#L161
Except we're not in IO and so I use SomeException
and try to force the result as best as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
'fdToHandle' is an abomination that corrupts the IOException fields.
No description provided.