X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=GHC%2FIO%2FHandle%2FText.hs;fp=GHC%2FIO%2FHandle%2FText.hs;h=c4906433456911a09576331e0b4ebd88fcb09999;hb=1d714d4281fd400253b7b887f77765a6b87148a0;hp=ebbacd43348569941f66cba9b24d9d333eb19633;hpb=7bd1a6a2d6ba6acfa19ffe46cb535f0ce427dc86;p=ghc-base.git diff --git a/GHC/IO/Handle/Text.hs b/GHC/IO/Handle/Text.hs index ebbacd4..c490643 100644 --- a/GHC/IO/Handle/Text.hs +++ b/GHC/IO/Handle/Text.hs @@ -31,6 +31,7 @@ import GHC.IO.FD import GHC.IO.Buffer import qualified GHC.IO.BufferedIO as Buffered import GHC.IO.Exception +import GHC.Exception import GHC.IO.Handle.Types import GHC.IO.Handle.Internals import qualified GHC.IO.Device as IODevice @@ -381,11 +382,14 @@ lazyReadBuffered h handle_@Handle__{..} = do debugIO ("hGetContents caught: " ++ show e) -- We might have a \r cached in CRLF mode. So we -- need to check for that and return it: - if isEOFError e - then if not (isEmptyBuffer buf) - then return (handle_', "\r") - else return (handle_', "") - else ioError e + let r = if isEOFError e + then if not (isEmptyBuffer buf) + then "\r" + else "" + else + throw (augmentIOError e "hGetContents" h) + + return (handle_', r) ) -- ensure we have some characters in the buffer