summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorThomas Miedema <thomasmiedema@gmail.com>2015-12-15 01:02:39 +0100
committerBen Gamari <ben@smart-cactus.org>2015-12-15 01:38:10 +0100
commit9017f16a78d66fe5aaf0ec98aeb9add1792fd838 (patch)
tree8fe96280ea78335a5d8fde3913e2a119f100e067 /libraries
parentddde542dbcb088e0a10aa3cdc3e0aef0a1c4a9b7 (diff)
downloadhaskell-9017f16a78d66fe5aaf0ec98aeb9add1792fd838.tar.gz
Mention "handle is semi-closed" in error messages
Semi-closedness is mentioned in the Haskell report, so lets not hide it from users. Reviewers: austin, hvr, bgamari Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1624
Diffstat (limited to 'libraries')
-rw-r--r--libraries/base/GHC/IO/Handle.hs10
-rw-r--r--libraries/base/GHC/IO/Handle/Internals.hs14
-rw-r--r--libraries/base/tests/IO/IOError001.stdout4
3 files changed, 16 insertions, 12 deletions
diff --git a/libraries/base/GHC/IO/Handle.hs b/libraries/base/GHC/IO/Handle.hs
index 23272cedd8..ac37ad45f9 100644
--- a/libraries/base/GHC/IO/Handle.hs
+++ b/libraries/base/GHC/IO/Handle.hs
@@ -113,7 +113,7 @@ hFileSize handle =
withHandle_ "hFileSize" handle $ \ handle_@Handle__{haDevice=dev} -> do
case haType handle_ of
ClosedHandle -> ioe_closedHandle
- SemiClosedHandle -> ioe_closedHandle
+ SemiClosedHandle -> ioe_semiclosedHandle
_ -> do flushWriteBuffer handle_
r <- IODevice.getSize dev
if r /= -1
@@ -129,7 +129,7 @@ hSetFileSize handle size =
withHandle_ "hSetFileSize" handle $ \ handle_@Handle__{haDevice=dev} -> do
case haType handle_ of
ClosedHandle -> ioe_closedHandle
- SemiClosedHandle -> ioe_closedHandle
+ SemiClosedHandle -> ioe_semiclosedHandle
_ -> do flushWriteBuffer handle_
IODevice.setSize dev size
return ()
@@ -473,7 +473,7 @@ hIsReadable handle =
withHandle_ "hIsReadable" handle $ \ handle_ -> do
case haType handle_ of
ClosedHandle -> ioe_closedHandle
- SemiClosedHandle -> ioe_closedHandle
+ SemiClosedHandle -> ioe_semiclosedHandle
htype -> return (isReadableHandleType htype)
hIsWritable :: Handle -> IO Bool
@@ -482,7 +482,7 @@ hIsWritable handle =
withHandle_ "hIsWritable" handle $ \ handle_ -> do
case haType handle_ of
ClosedHandle -> ioe_closedHandle
- SemiClosedHandle -> ioe_closedHandle
+ SemiClosedHandle -> ioe_semiclosedHandle
htype -> return (isWritableHandleType htype)
-- | Computation 'hGetBuffering' @hdl@ returns the current buffering mode
@@ -503,7 +503,7 @@ hIsSeekable handle =
withHandle_ "hIsSeekable" handle $ \ handle_@Handle__{..} -> do
case haType of
ClosedHandle -> ioe_closedHandle
- SemiClosedHandle -> ioe_closedHandle
+ SemiClosedHandle -> ioe_semiclosedHandle
AppendHandle -> return False
_ -> IODevice.isSeekable haDevice
diff --git a/libraries/base/GHC/IO/Handle/Internals.hs b/libraries/base/GHC/IO/Handle/Internals.hs
index 99cfb312a8..37251abd06 100644
--- a/libraries/base/GHC/IO/Handle/Internals.hs
+++ b/libraries/base/GHC/IO/Handle/Internals.hs
@@ -42,7 +42,8 @@ module GHC.IO.Handle.Internals (
decodeByteBuf,
augmentIOError,
- ioe_closedHandle, ioe_EOF, ioe_notReadable, ioe_notWritable,
+ ioe_closedHandle, ioe_semiclosedHandle,
+ ioe_EOF, ioe_notReadable, ioe_notWritable,
ioe_finalizedHandle, ioe_bufsiz,
hClose_help, hLookAhead_,
@@ -238,7 +239,7 @@ checkWritableHandle :: (Handle__ -> IO a) -> Handle__ -> IO a
checkWritableHandle act h_@Handle__{..}
= case haType of
ClosedHandle -> ioe_closedHandle
- SemiClosedHandle -> ioe_closedHandle
+ SemiClosedHandle -> ioe_semiclosedHandle
ReadHandle -> ioe_notWritable
ReadWriteHandle -> do
buf <- readIORef haCharBuffer
@@ -277,7 +278,7 @@ checkReadableHandle :: (Handle__ -> IO a) -> Handle__ -> IO a
checkReadableHandle act h_@Handle__{..} =
case haType of
ClosedHandle -> ioe_closedHandle
- SemiClosedHandle -> ioe_closedHandle
+ SemiClosedHandle -> ioe_semiclosedHandle
AppendHandle -> ioe_notReadable
WriteHandle -> ioe_notReadable
ReadWriteHandle -> do
@@ -307,7 +308,7 @@ checkSeekableHandle :: (Handle__ -> IO a) -> Handle__ -> IO a
checkSeekableHandle act handle_@Handle__{haDevice=dev} =
case haType handle_ of
ClosedHandle -> ioe_closedHandle
- SemiClosedHandle -> ioe_closedHandle
+ SemiClosedHandle -> ioe_semiclosedHandle
AppendHandle -> ioe_notSeekable
_ -> do b <- IODevice.isSeekable dev
if b then act handle_
@@ -316,13 +317,16 @@ checkSeekableHandle act handle_@Handle__{haDevice=dev} =
-- -----------------------------------------------------------------------------
-- Handy IOErrors
-ioe_closedHandle, ioe_EOF,
+ioe_closedHandle, ioe_semiclosedHandle, ioe_EOF,
ioe_notReadable, ioe_notWritable, ioe_cannotFlushNotSeekable,
ioe_notSeekable :: IO a
ioe_closedHandle = ioException
(IOError Nothing IllegalOperation ""
"handle is closed" Nothing Nothing)
+ioe_semiclosedHandle = ioException
+ (IOError Nothing IllegalOperation ""
+ "handle is semi-closed" Nothing Nothing)
ioe_EOF = ioException
(IOError Nothing EOF "" "" Nothing Nothing)
ioe_notReadable = ioException
diff --git a/libraries/base/tests/IO/IOError001.stdout b/libraries/base/tests/IO/IOError001.stdout
index 1e689bb0f9..c235b62eda 100644
--- a/libraries/base/tests/IO/IOError001.stdout
+++ b/libraries/base/tests/IO/IOError001.stdout
@@ -1,2 +1,2 @@
-<stdin>: hGetChar: illegal operation (handle is closed)
-<stdin>: hGetChar: illegal operation (handle is closed)
+<stdin>: hGetChar: illegal operation (handle is semi-closed)
+<stdin>: hGetChar: illegal operation (handle is semi-closed)