我试图逐项排除因阅读功能造成的例外情况:
run :: CurrentData -> IO ()
run current = do
{
x <- (getCommandFromUser) `E.catch` handler;
updated <- executeCommand x current;
run updated;
} where handler :: E.IOException -> IO Command
handler e = do putStrLn "wrong command format" >> return (DoNothing);
In this code function getCommandfrom user gets some string from user and then tries to read some data from this string using "read" function
If read fails there is exception thrown:
*** Exception : prelude.read : no parse
and program exits... I can t catch this exception - what is type of this exception???
我还尝试了E.SomeException,而不是E.IOException...。
E is from import Control.Exception As E