[Haskell-cafe] Catching an escaping exception
joelr1 at gmail.com
Fri Nov 4 07:15:30 EST 2005
How can I catch this exception and translate it into an error within
The exception is going to ghci and is not being caught in the monad.
I'm interested in catching it and failing the monad gracefully.
<interactive>: connect: does not exist (Connection refused)
type EngineState = ErrorT String (StateT World IO)
type EngineResult = IO (Either String (), World)
connect :: [Prop] -> HostName -> Int -> EngineState ()
connect env h p =
do w <- get
let secs = timeout_seconds w
(Right h) <- liftIO $ timeout secs $ connect_ h p
trace "Connection established"
connect_ :: HostName -> Int -> IO Handle
connect_ h p = connectTo h $ PortNumber $ fromIntegral p
timeout :: forall a.Int -> IO a -> IO (Either String a)
timeout seconds action =
More information about the Haskell-Cafe