on master help sign in
catch errors during receive and report them
b7710bcHannes Mehnert
src/Idris/IdeSlave.hs+3−3
@@ -95,14 +95,14 @@ receiveString x =
95 ((num, ""):_) ->
95 ((num, ""):_) ->
96 let msg = drop 6 x in
96 let msg = drop 6 x in
97 if (length msg) /= (num - 1)
97 if (length msg) /= (num - 1)
98− then error "bad input"
98+ then error "bad input length"
99 else parseSExpToCommand msg
99 else parseSExpToCommand msg
100− _ -> error "blah"
100+ _ -> error "readHex failed"
101
101
102parseSExpToCommand :: String -> Maybe IdeSlaveCommand
102parseSExpToCommand :: String -> Maybe IdeSlaveCommand
103parseSExpToCommand msg =
103parseSExpToCommand msg =
104 case parseSExp msg of
104 case parseSExp msg of
105− Left _ -> Nothing
105+ Left _ -> error "parse failure"
106 Right r -> sexpToCommand r
106 Right r -> sexpToCommand r
107
107
108sendMessage :: SExpable a => a -> IO ()
108sendMessage :: SExpable a => a -> IO ()
src/Idris/REPL.hs+15−14
@@ -84,20 +84,21 @@ repl orig mods
84-- | Run the IdeSlave
84-- | Run the IdeSlave
85ideslave :: IState -> [FilePath] -> Idris ()
85ideslave :: IState -> [FilePath] -> Idris ()
86ideslave orig mods
86ideslave orig mods
87− = do x <- liftIO $ receiveMessage
87+ = do idrisCatch (do x <- liftIO $ receiveMessage
88− case x of
88+ case x of
89− Nothing -> do liftIO $ sendMessage (Just "did not understand")
89+ Nothing -> do liftIO $ sendMessage (Just "did not understand")
90− Just (Interpret cmd) -> do i <- getIState
90+ Just (Interpret cmd) -> do i <- getIState
91− let fn = case mods of
91+ let fn = case mods of
92− (f:_) -> f
92+ (f:_) -> f
93− _ -> ""
93+ _ -> ""
94− case parseCmd i cmd of
94+ case parseCmd i cmd of
95− Left err -> do liftIO $ sendMessage (show err)
95+ Left err -> do liftIO $ sendMessage (show err)
96− Right cmd -> do idrisCatch (do xs <- process fn cmd
96+ Right cmd -> do idrisCatch (do xs <- process fn cmd
97− liftIO $ sendMessage xs)
97+ liftIO $ sendMessage xs)
98− (\e -> do liftIO $ sendMessage (show e))
98+ (\e -> do liftIO $ sendMessage (show e))
99− Just y -> do liftIO $ sendMessage (Just "understood you!")
99+ Just y -> do liftIO $ sendMessage (Just "understood you!")
100− liftIO $ sendMessage (Just "Hello world")
100+ liftIO $ sendMessage (Just "Hello world"))
101+ (\e -> do liftIO $ sendMessage (show e))
101 ideslave orig mods
102 ideslave orig mods
102
103
103-- | The prompt consists of the currently loaded modules, or "Idris" if there are none
104-- | The prompt consists of the currently loaded modules, or "Idris" if there are none