on master help sign in
catch errors during receive and report them
commitb7710bc195f16313202be78625d2bbc44bbe7fe8 authorHannes Mehnert <hannes@mehnert.org> dateThu 11 Apr 2013, 16:32 (14 years ago) parent1b65f6a
2 files changed+18−17
src/Idris/IdeSlave.hs+3−3 src/Idris/REPL.hs+15−14
src/Idris/IdeSlave.hs+3−3
@@ -95,14 +95,14 @@ receiveString x =
9595 ((num, ""):_) ->
9696 let msg = drop 6 x in
9797 if (length msg) /= (num - 1)
98− then error "bad input"
98+ then error "bad input length"
9999 else parseSExpToCommand msg
100− _ -> error "blah"
100+ _ -> error "readHex failed"
101101
102102parseSExpToCommand :: String -> Maybe IdeSlaveCommand
103103parseSExpToCommand msg =
104104 case parseSExp msg of
105− Left _ -> Nothing
105+ Left _ -> error "parse failure"
106106 Right r -> sexpToCommand r
107107
108108sendMessage :: SExpable a => a -> IO ()
src/Idris/REPL.hs+15−14
@@ -84,20 +84,21 @@ repl orig mods
8484-- | Run the IdeSlave
8585ideslave :: IState -> [FilePath] -> Idris ()
8686ideslave orig mods
87− = do x <- liftIO $ receiveMessage
88− case x of
89− Nothing -> do liftIO $ sendMessage (Just "did not understand")
90− Just (Interpret cmd) -> do i <- getIState
91− let fn = case mods of
92− (f:_) -> f
93− _ -> ""
94− case parseCmd i cmd of
95− Left err -> do liftIO $ sendMessage (show err)
96− Right cmd -> do idrisCatch (do xs <- process fn cmd
97− liftIO $ sendMessage xs)
98− (\e -> do liftIO $ sendMessage (show e))
99− Just y -> do liftIO $ sendMessage (Just "understood you!")
100− liftIO $ sendMessage (Just "Hello world")
87+ = do idrisCatch (do x <- liftIO $ receiveMessage
88+ case x of
89+ Nothing -> do liftIO $ sendMessage (Just "did not understand")
90+ Just (Interpret cmd) -> do i <- getIState
91+ let fn = case mods of
92+ (f:_) -> f
93+ _ -> ""
94+ case parseCmd i cmd of
95+ Left err -> do liftIO $ sendMessage (show err)
96+ Right cmd -> do idrisCatch (do xs <- process fn cmd
97+ liftIO $ sendMessage xs)
98+ (\e -> do liftIO $ sendMessage (show e))
99+ Just y -> do liftIO $ sendMessage (Just "understood you!")
100+ liftIO $ sendMessage (Just "Hello world"))
101+ (\e -> do liftIO $ sendMessage (show e))
101102 ideslave orig mods
102103
103104-- | The prompt consists of the currently loaded modules, or "Idris" if there are none