catch Error_EOF exception and return empty data.

This commit is contained in:
Vincent Hanquez 2014-03-23 10:55:39 +00:00
parent beb4e7c67d
commit 8653d49a42

View file

@ -72,9 +72,14 @@ sendData ctx dataToSend = liftIO (checkValid ctx) >> mapM_ sendDataChunk (L.toCh
recvData :: MonadIO m => Context -> m B.ByteString
recvData ctx = liftIO $ do
checkValid ctx
E.catchJust (\Error_EOF -> Just ())
doRecv
(\() -> return B.empty)
where doRecv = do
pkt <- withReadLock ctx $ recvPacket ctx
either onError process pkt
where onError err@(Error_Protocol (reason,fatal,desc)) =
onError err@(Error_Protocol (reason,fatal,desc)) =
terminate err (if fatal then AlertLevel_Fatal else AlertLevel_Warning) desc reason
onError err =
terminate err AlertLevel_Fatal InternalError (show err)