catch Error_EOF exception and return empty data.
This commit is contained in:
parent
beb4e7c67d
commit
8653d49a42
1 changed files with 8 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue