Skip to content

Commit

Permalink
Server: ignore all connection exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar committed Jan 26, 2024
1 parent c72daf0 commit 252e382
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Network/WebSockets/Typed/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Control.Monad.RWS (MonadState (put))
import Data.ByteString (ByteString)
import Data.ByteString.Char8 (unpack)
import Data.Foldable (for_)
import Data.Maybe (isNothing)
import Network.WebSockets qualified as WS
import Network.WebSockets.Connection.PingPong qualified as PingPong
import Network.WebSockets.Typed.Session qualified as Session
Expand All @@ -24,7 +25,7 @@ data Options a = Options
{ handlePendingConnection :: (ClientConnection a) => WS.PendingConnection -> IO (Maybe a),
pingPongOptions :: WS.PingPongOptions -> IO WS.PingPongOptions,
messageLimit :: Int,
-- handler for sync exceptions, not raised for ConnectionClosed
-- handler for sync exceptions, ignoring WS.ConnectionException
onHandleException :: WS.PendingConnection -> SomeException -> IO ()
}

Expand Down Expand Up @@ -65,5 +66,5 @@ run uriBS options app receiveApp = do

handler :: WS.PendingConnection -> SomeException -> IO ()
handler pendingConnection exc = do
when (fromException exc /= Just WS.ConnectionClosed) $
when (isNothing $ fromException @WS.ConnectionException exc) $
onHandleException options pendingConnection exc

0 comments on commit 252e382

Please sign in to comment.