@@ -297,16 +297,18 @@ connectProjectM36 (RemoteConnectionInfo dbName hostName servicePort notification
297297 \(NotificationMessage notifications') ->
298298 forM_ (M.toList notifications') (uncurry notificationCallback)
299299 ]
300−-- TODO missing async callback
301− conn <- RPC.connect notificationHandlers (hostAddressToTuple addr) port
302− eRet <- RPC.call conn (Login dbName)
303−-- TODO handle connection errors
304− case eRet of
305− Left err -> error (show err)
306− Right False -> error "wtf"
307− Right True ->
300+ let connectExcHandler (e :: IOException) = pure $ Left (IOExceptionError e)
301+ eConn <- (Right <$> RPC.connect notificationHandlers (hostAddressToTuple addr) port) `catch` connectExcHandler
302+ case eConn of
303+ Left err -> pure (Left err)
304+ Right conn -> do
305+ eRet <- RPC.call conn (Login dbName)
306+ case eRet of
307+ Left err -> error (show err)
308+ Right False -> error "wtf"
309+ Right True ->
308310 --TODO handle connection errors!
309− pure (Right (RemoteConnection (RemoteConnectionConf conn)))
311+ pure (Right (RemoteConnection (RemoteConnectionConf conn)))
310312
311313--convert RPC errors into exceptions
312314convertRPCErrors :: RPC.ConnectionError -> IO a